I an using knitr for automatic html reports. I would like to be able to plot simple scatter plots (like time serie plots) but interactive ones, that would be zoomable.
Ideally I could then use it in a knitr html document.
I had a look at rgl but it seems overkill for my simple needs. What should I use ?
Have a look into ggvis and/or rCharts.
Especcaly have a look at this example page of stock-data with rCharts:
http://timelyportfolio.github.io/rCharts_time_series/history.html
"rCharts 2013" might be interessting for you.
And this is an example of Markdown with knitr and rCharts:
http://rstudio-pubs-static.s3.amazonaws.com/9331_9b5778029d1e46d0b3afcf1d861d7e70.html
Related
I use Gnuplot for most of my plots and save the plots as a png. But the resolution of the plots are not so good to put in research papers. So, I need help regarding the following two things:
How to prepare publication-quality plots (eps) in Gnuplot?
How to use calligraphic fonts in the plot, like those written using \mathcal{} in latex?
I searched on the internet regarding these two things, but could not get any ideas.
Thanks in advance.
Since you are stating LaTeX code in your question, I suppose that a solution including LaTeX is suitable for you. I am using gnuplot for producing publication-quality plots (and even TOC-figures!) too, and for me the most convenient method is to use the cairolatex standalone terminal, use LaTeX syntax (e.g. \mathcal{}) in the labels, plot titles and so on, and to compile the figures with pdfLaTeX. Often enough, journals accept figures not only in .eps, but also in .pdf format. If a journal was to refuse .pdf, I would simply convert the figure in the end (i.e. right before submission) to .eps, .png or whatever.
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 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.
I am new to using R Markdown and am trying to get my plots on the output to look the same as the plot that shows in the plot window of RStudio. Below is the code I have been using for the R Markdown page:
```{r rawplot, message=FALSE, echo=FALSE, fig.width=7.65, fig.height=5.88}
sept13 <- ggplot(sept_13, aes(x=transactiondate, y=amount))
sept13 + geom_line(aes(color=type, group=type)) +
labs(title="Daily Payment Amounts in Sept 2013", x="Date", y="Amount Paid")
```
And this is the image it will produce on the output page.
However, that is not how I would like it to look. When the plot is generated in RStudio the plot window produces this image. I have fiddled around with the fig.width and fig.height options in R Markdown but I just can't get it to look right. Is there something I'm forgetting or is there a way to get the plot to 'autofit' the output page? Any help would be greatly appreciated, thanks.
It looks to me like the data is quite different in those two plots. I suspect you are not really given them the same data, that is an easy mistake to make since you have to maintain two different sources. I have had exactly this problem several times in the past.
Try listing the data behind the plots in both cases (you can do that in markdown as well) and examine them closely.
If they are the same then augment your question with both of those listings.
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