Is it possible for googleVis Package from R to generate Images as oppose to interactive charts? To create a GoogleVis Chart in R:
library(googleVis)
M <- gvisMotionChart(Fruits, "Fruit", "Year")
plot(M)
This initiates a browser and then it will plot an interative chart. Is there a way such that I can create a non-interactive image and plot it in R
What I have done is a complete hack, but it works. I view the HTML for the googleVis object generated and extract the svg. I save the svg as a file and open it in an image editor that can open and convert svg files.
There's no real need to use googleVis for this. If you create your plot in ggplot2, the ggthemes add-on package has theme_gdocs(), and associated colour palettes that will let you style your chart exactly like a Google Chart.
It looks like the only way to do this is to make the interactive plot, and take a screenshot. The object returned by googleVis is a Flash application embedded in html, I think you probably cannot expect it to give a static plot!
Some hacks I found that could potentially be able to convert gvis charts to images:
http://html2canvas.hertzen.com/
https://gist.github.com/battlehorse/1333906
Related
I want to make a windrose plot on a specific location. Windrose can be plot with openair package
library(openair)
windRose(mydata, "ws", "wd")
or with ggplot using this function. What I am looking for, a nice way to overlay this plot on a map. I tried with ggmap (I don't have a google map API key) and leaflet. This example also I tried, the output is below.
Is there a way to overlay ggplot on leaflet map or any other ggmap way to do it nicely.
That is a multi-step process and will take a bit of tweaking to make it work the way you want but it can be done in 3 steps.
Set the background of your chart to transparent
Save a png locally
Use addLogo() from mapview package to post the image to your map and place it
For sure you will need to problem solve some as you implement this process. If you are doing this in Shiny you would want to use directory management to create and destroy the plots as data updates and be sure to make the creation of the graph reactive or observed in some way.
If you are making a nice rMarkdown dashboard, just make sure you keep track of where the png file saves and use the proper addressing.
ggplot2 is able to export plots in vector formats like SVG. Plots rendered in Shiny with plotOutput() are rendered in PNG format. Is it possible to render Shiny plots in SVG format?
It is possible to output ggplots in a Shiny app as vectors thanks to the package ggiraph, by David Gohel. The package also supports basic interactivity to ggplot2 plots, like tooltips, highlighting, and more.
I have some code that generates a plotly image in R. Previously I included this plot in a presentation using Rstudio/ioslides. The people I am collaborating with want a version in powerpoint. I am trying to use the ReporterRs package in order to create an re-producible shell powerpoint presentation with all of my plots. However ReporterRs only accepts lattice, ggplot2, and base images. Since there is a way to convert ggplot2 objects to plotly images I was hoping there was a way to go backwards. However I am stuck. I have been unable to "downgrade" my plotly plots to ggplot2. Does anyone know if there is a way to do this?
(I know I can just copy and paste them over but I would like to develop a workflow where I can create easily reproducible and replaceable plots so that I don't have to do very much work if I change the data)
I want to create a new figure with interactive R-plots (with tooltips).
To show how I wish to have my plots I give an example using the mtcars data. I am using the package scatterD3 to get tooltips:
library(scatterD3)
data(mtcars)
tooltips <- paste('This is an incredible <strong>',rownames(mtcars),'</strong><br />with',mtcars$cyl,'cylinders !')
scatterD3(x=mtcars$wt,y=mtcars$mpg,tooltip_text=tooltips)
Now I don't want only one plot of this type in one figure. Usually it is possible to use par(mfrow=(i,j)) to create a figure with more than one plot. But it seems not to work for my interactive plots. Is there a way to do this?
Have you given a look to the plotly R package?
It has also a function to render the ggplots in ggplotly
An idea could be to create a multiplot with ggplot2 and than render it with ggplotly.
I've not yet tried it, so I don't know if it's really possible.
In shiny apps ggplot2 graphs can easily be downloaded based on the downloadHandler function. Is it possible to download the javascript visualisations that are produced by means of rCharts in a similar way? If yes, what is the best approach?
If you use the HighCharts capability of rCharts then you can use it's exporter feature which has an download capability as demonstrated here (source).
If not, you're left with DOM introspection like I ended up using here. That has no R behind it, but it shows how to find the SVG in the DOM and make it so the graphic is exportable in a couple different ways.