Reputation: 33
I want to create a scatter plot that will link points that share a particular attribute when hovered over and also display a tooltip, similar to the example here https://i.sstatic.net/fAWem.gif
I am currently using ggvis to make the plot, although I'm not sure it supports this functionality. The visualization will be displayed in shiny.This is what my code to make the visualization looks like at the moment. The categorical variable that I want the points to be joined by is Choice_2
.
plot_data %>%
ggvis(x= ~X,y= ~Y, size= ~Size_val,stroke := "white") %>%
layer_points(fill= ~Choice_1, opacity := I(2/5)) %>%
scale_numeric(property = 'size', domain = c(0.01,0.52),range = c(100,5200))%>%
hide_legend(scales = 'size') %>%
bind_shiny("ggvis", "ggvis_ui")
Any help or references would be much appreciated.
Upvotes: 0
Views: 261
Reputation: 29387
As mentioned by @vck look into Rcharts
. Note that the example is taken from here
library(rCharts)
r1<- nPlot(mpg ~ wt, group = 'cyl', data = mtcars, type="scatterChart")
r1$chart(tooltipContent = "#! function(key, x, y, e,graph){
return '<b>carb</b>: ' + e.point.carb
} !#")
r1$chart(size = '#! function(d){return d.disp} !#')
r1
Upvotes: 1