Hi all, I have a plot that pretty much gives me everything I want in terms of aesthetics (except the 'Not assigned' category should be shown in grey in the legend, but I never got that snippet of code to work... oh well...). Here is my code:
Picornas_for_interactive_graph3 <- ggplot(justPicorna_contiginfo, aes(x = kmer_cov, y = percid, size = querylength, color = family, text = subject_title)) + geom_point(alpha = 1) + geom_point(data = subset(justPicorna_contiginfo, family == "Not assigned"), aes(x = kmer_cov, y = percid), color = "darkgrey", shape = 16) + scale_x_log10() + scale_size(range = c(5, 20), name="query length") + scale_color_viridis_d(option = "turbo", alpha = 1, begin = 0.05, end = 0.5, direction = -1) + labs(x = "kmer coverage", y = "percent identity (%)", color = "family") + # Update the color legend title theme(plot.margin = margin(2, 2, 2, 2, "cm"), axis.title.x = element_text(size = 18), axis.title.y = element_text(size = 18), legend.title.position = "top", axis.text = element_text(size=14), legend.title = element_text(size = 16, color = "darkblue"), legend.text = element_text(size = 16), legend.position = "right", legend.direction = "vertical", legend.spacing.y = unit(0, "lines")) + guides(color = guide_legend(override.aes = list(size = 5, alpha = 1)), size = guide_legend(override.aes = list(alpha = 0.7, color = "darkgrey")))
And this is what my output looks like:
However, I need to make my graph interactive and that is when I start experiencing trouble. I use this code:
Picornas_for_interactive_graph3_trial <- ggplotly(Picornas_for_interactive_graph3, tooltip = c("text","x","y", "size"))
And this is what my graph looks like:
As you can see, some of the features of my organized legend are lost. I need a "query length" category in my legend as it is crucial for an audience to get a feel for how long the sequences are. I also had to change some of the aesthetics of my original ggplot because ggplotly doesn't seem to support them. If anyone has insights on how to fix my legend (or any other tips and tricks for ggplotly), I would greatly appreciate the help!
Thanks so much!
Thank you Jared for your response. I took a look at the documentation you provided and am trying my best to follow along, but can't seem to figure this out. I went ahead and created a plot similar to the one I did on ggplot using baseR (not exactly what I want it to look like yet, but almost):
However, the issue once again arises when I try to make the graph interactive and am lost with how to add traces and markers for my situation. I have a class presentation for this research on Thursday so my main concern is not having enough time to work on my presentation if I keep troubleshooting this. With that said, I'd appreciate any additional feedback regarding my code, and already appreciate the help so much!
Thanks :)
Again, this is not particularly difficult to do with plotly itself - the syntax is pretty similar to ggplot.