The group function in dygraphs is particularly useful for a series of related plots if you want to x-axis zoom in unison. I was looking for a feature or parameter that would also allow the mouseover legend values to be synchronized across the grouped dygraphs. I see some functionality in the package relating to mouseover, however nothing with x or y coordinates in R.
This would be for use in a shinyapp.
Related
I am creating a flexdashboard with R markdown / shiny.
Assumed the dashboard has two identical scatter plots. Is there a way to synchronize the two charts, if I zoom into one of them? Which is the best package to achieve this and to have it on the flexdashboard?
I tried Plotly. But there I could only synchronize one axis, but not both at the same time. If the charts are vertically oriented it would synchronize the x axis, and if horizontally oriented it would synchronize the y axis.
I am still trying dygraph. I have the impression by grouping the charts, I might be able to synchronize the zoom. Is that right? Would it synchronize both axis at the same time? (Only problem, this is mainly a time series tool, and not meant for scatter plots, i.e. not for data with more than one value per x value. At least this is my impression.)
Is there a package able to handle x and y axis synchronization at the same time? Or did I miss anything with Plotly/dygraph?
Thanks for your help.
For those interested. Rbokeh does scatterplots and allows synchronizing both axes. Use the grid_plot function to plot your charts and set same_axes = TRUE.
dygraphs synchronizes only the date range (x axis), if you set the parameter group. To synchronize the y axis you can try to get the zoom callback and to apply the zoom level to the other plot.
Is it possible to add plot interactions such as zooming as shown here and panning to charts plotted with the chartseries function from quantmod?
I am trying to find a decent yet simple solution for charting financial data (mainly candlesticks) with R. The standard chartseries plots are ok but severely lack a nice zooming functionality. I've use DYGRaphs and gvis packages but they struggle with plotting a non-continuous timeseries on the x-axis (i.e they have gaps in the data for weekends.) Gvis can over come this by using a discrete x-axis but then you lose the dates as labels. The other issue with these is that they dont have the nice integration of the indicators and trades on the plot that quantmod gives you.
I'm fairly new to R, but after spending several days exploring all the options for charting financial data and not finding a half decent solution, I think I'm barking up the wrong tree. Is there any sort of industry standard that I've completely missed?
I am trying to build an interactive plot. It has properties between a scatterplot and a network - I have a list of nodes and edges (network), but I also would like to constrain the nodes, sometimes on the x-axis sometimes on both x- and y- axis (scatterplot). Finally, I have a text label associated with each node that I would like to display (instead of a dot). I was able to create this using ggplot2.
However, some data sets are too large for this to work without the text labels from each node overlapping. Hence, I would now like to add an interactive feature so that the plot consists of dots representing each node, but that upon UI (such as hovering over a dot), the text label belonging to that dot will be revealed.
I would like to achieve this using R.
I tried animint (https://github.com/tdhock/animint) but it seems to mostly allow interaction between two plots, and here I would like to keep it all in one plot.
I also tried htmlwidgets (http://www.htmlwidgets.org/). I looked at two of their packages: I tried using metricsgraphics (mjs_plot), as it has a show_rollover_text option and mouseover option. However, this package does not allow combination of geoms, and so I could not have both dots (nodes) and lines (edges) represented. I also tried network3D package, but that seems to automatically position nodes so that they are distanced far away from each other, and does not seem to provide options to fix each node on a given x and y location.
I am just looking for advice on any other packages I should maybe consider to solve this problem and/or if I may be missing a feature from a package I already tried that could solve this problem. Thank you.
Maybe identify() will be useful for you. But it works only for base plotting system.
x <- rnorm(300)
y <- rnorm(300)
labs <- seq(300)
plot(x,y)
identify(x,y, labels = labs, plot=TRUE)
identify pic
I just came into a problem while making several maps in R, the problem I came to is that I want to plot several maps and some geom_points in those maps, each map will have some points with different values and so the legend with the scales (size and color) will change between maps. All I want is to have exactly the same legend, representing the same values (for both color and size). I've tried with breaks etc but my data is continuous, so I didn't find any way to fix it.
EDIT:Simple example
Will try to explain with simple example by myself. Imagine I have these two arrays to be plotted into different coordinates for 2 different days:
c<-(1,2,3,2,1)
c<-(1,9,2,1,2)
What I want is to set the legend of the plot to be always representing the range 1-9 as values of the geom_points, no matter the specific values of the given day, in a way that no matter the values, the legend will be always the same and if I try to set some slides, the scale will not change
Any ideas?
Using R I would like to replace the points in a 2d scatter plot by a pie chart displaying additional values.
The rational behind is that I have time series data for hundreds of elements (proteins) derived from a biological experiment monitored for 4 conditions. I would like to plot the elements (categorial data) on the y axis and occurrence of a event in time on the x axis. To visualize the relative occurrence between the 4 conditions I would like to visualize this in form of a pie chart or doughnut chart overplayed onto the respective point in the scatter plot.
The overall data density is low so overlapping won't be an issue.
Is this possible in R?
I was thinking of using a manual scale in ggplot2 but could not figure out how to define a pie chart as a scale.
Also of interest would be how to best cluster this data and sort it accordingly.
Yes. pieGlyph() is one ready-to-go function from the Rgraphviz package.
Also, I would check out this Q/A for how to do things like this more generally:
How to fill a single 'pch' point on the plot with two-colours?
Especially check out ?my.symbols from the TeachingDemos package.
Lastly, in regards to ggplot2, you should check out this blog post about possible upcoming features:
http://blog.revolutionanalytics.com/2011/10/ggplot2-for-big-data.html
See also Paul Murrell. Integrating grid graphics output with base graphics output. R News, 3(2):7-12, October 2003. http://www.r-project.org/doc/Rnews/Rnews_2003-2.pdf
The code on pp 10-11 sets up the main plot axes, labels and legend, and then opens a series of smaller windows centered at each individual point on the plot and plots a small graph in each window. I've tried pie charts, mosaics and barplots, but the method is not limited to these types.