title: show x and y co-ordinates on line plot
body: <p>I am new to R Script and coding, just inherited some R Code that I which plots perfectly fine and gives the correct results. I want to have the ability to show the x and y values when a user hovers the mouse cursor over the line. </p>
  
  <p>I have found a link to a articles that describe how to carry out the necessary step but having no luck at all..</p>
  
  <p>[url=" <a href="https://www.r-graph-gallery.com/124-change-hover-text-in-plotly/" rel="nofollow noreferrer">https://www.r-graph-gallery.com/124-change-hover-text-in-plotly/</a>"]</p>
  
  <pre><code>library(dplyr)
  library(ggplot2)
  library(survival)
  library(survminer)
  library(grid)
  library(gridExtra)
  library(plotly)
  pc &lt;- dataset
  fstat &lt;- pc %&gt;% mutate(fstatus = case_when(OUTCOMETYPE=="Revised" ~ 1,TRUE ~ 0))
  pmpa &lt;- fstat %&gt;% select(PRIMARYPROCEDUREID,PRIMARYTOOUTCOMEYEARS,fstatus,OUTCOMETYPE)
  if(nrow(pmpa) &lt; 4){
  d &lt;- pmpa %&gt;% select(PRIMARYPROCEDUREID,PRIMARYTOOUTCOMEYEARS,OUTCOMETYPE) %&gt;% mutate(INSUFFICIENTDATA = "Summary Results")
  h = head(d[,2:4])
  grid.table(h)
  }else{
  fit &lt;- survfit(Surv(PRIMARYTOOUTCOMEYEARS,fstatus)~1,data = pmpa) 
  ggsurv &lt;- ggsurvplot(fit,
             ylab="Patient Analysis",
             xlab="Time (Years)",
             break.time.by = 1,
             xlim = c(0,max(fit$time)),
             surv.scale = "percent",
             legend.title = "Kaplan-Meier",
             legend.labs = "",
             risk.table = TRUE,
             fontsize = 3,
             font.tickslab = c(10, "plain"),
             risk.table.y.text = FALSE,
             fun = "event"
             )
  ggsurv$plot &lt;- ggsurv$plot + theme(plot.title = element_text(hjust = 0.5, size=18), panel.grid.major = element_line(colour ="grey90"))
  ggsurv$table &lt;- ggsurv$table + theme(plot.title = element_text(hjust = 0.5, size = 10))
  
  ggsurv
  </code></pre>
  
  <p>the ability to see only the x and y co-ordinates nothing else on hoover on line chart.</p>