0

According to this post it seems like I should just be able to to put the variable name holding the plot into the ggplotly function and then the graph should have mouseover points. The data points do not display anything when I scroll the mouse over in adobe reader nothing displays. I would like to be able to write my own custom labels for each point.

install.packages(c("devtools"))
library(devtools)
dev_mode(on=T)
install_github("hadley/ggplot2")
install.packages(c("ggplot2"))
library(ggplot2)
install.packages(c("plotly"))   #Select mirror ("USA (WA)")
library("plotly")
install.packages(c("Cairo"))
library("Cairo")
all_rates = read.csv("file.txt")

for(i in unique(gsub('_[0-9]+', '', all_rates[,1]))){
        rates <- all_rates[grep(i, all_rates[,1]),]
        freq = unlist(rates[2])
        temp = unlist(rates[3])
        exn = unlist(rates[4])
        p = ggplot(rates, aes(freq,temp)) + geom_point(data=rates, aes(freq,temp,group=factor(exn),colour=factor(exn))) + geom_smooth(data=rates, aes(freq,temp,group=factor(exn),colour=factor(exn)),method = "lm",fill=NA)
        ggplotly(p)
        ggsave(paste0(i, ".pdf"))
}

I still get

We recommend that you use the dev version of ggplot2 with `ggplotly()`
Install it with: `devtools::install_github('hadley/ggplot2')`

As a warning. I was under the impression that I was using this version though based on this post

This is the output I get after all the checks and creates for the packages

The downloaded source packages are in
    '/tmp/Rtmpo0GRLE/downloaded_packages'
We recommend that you use the dev version of ggplot2 with `ggplotly()`
Install it with: `devtools::install_github('hadley/ggplot2')`
Saving 7 x 7 in image
We recommend that you use the dev version of ggplot2 with `ggplotly()`
Install it with: `devtools::install_github('hadley/ggplot2')`
Saving 7 x 7 in image

file.txt

clothing,freq,temp,exn
coat_1,0.3,10,1
coat_1,0.9,0,1
coat_1,0.1,20,1
coat_2,0.5,20,2
coat_2,0.3,15,2
coat_2,0.1,5,2
scarf,0.4,30,1
scarf,0.2,20,1
scarf,0.1,10,1
Sam
  • 491
  • 8
  • 52
  • 142
  • 1
    I think the problem is with you saving the graphs to pdf. You need html to have a mouse-over effect. If you just run through your code for, say, `i – ekstroem Jul 29 '17 at 05:53
  • Could you explain more please. `i – Sam Jul 30 '17 at 22:11
  • If you drop your `for` loop, remove the line with `ggsave()`, and assign `i – ekstroem Jul 31 '17 at 00:10
  • Theres no plots when I do that. I just get `The downloaded source packages are in '/tmp/RtmpMrEXX2/downloaded_packages' We recommend that you use the dev version of ggplot2 with `ggplotly()` Install it with: `devtools::install_github('hadley/ggplot2')`` – Sam Jul 31 '17 at 20:13

0 Answers0