Rggobi ggplot like pdf output - r

Good day everyone. I have a question concerning ggobi and rggobi package. I am using R version 2.13.2 and Ubuntu 11.04. I am new to ggobi and I'm reading the book Interactive and Dynamic Graphics for Data Analysis. The book was published 2007.
My question is: how can I export a graph for rggobi to pdf to include it in latex. For example: I have lots of variables in ggobi and I need to export the ggplot like scatterplot of any two variables or parallel cordinates graph to a pdf. So far I've read that the authors suggests to solve it like this:
library(DescribeDisplay)
d <- dd_load("fig.R")
plot(d)
or
p <- ggplot(d)
print(p)
which produces nice graphics which you can use with pdf() function.
But neither the DescribeDisplay package, nor ggplot are available in 2.13.2.
I browsed the web for solution, but I found only that ggobi_display_save_picture() could be useful for image graphs but not for pdf. I also tried save display description (tools->save display description) and then plotting it with qplot() or plot(). But all I get is a blank screen while ggobi_display_save_picture() gives a good picture. There is probably a much easier solution since R is changing and becoming more convenient to use.

Related

How to prepare publication-quality plots and use calligraphic fonts in Gnuplot?

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.

in Rstudio keras library what is ggplot2 code to generate history plot

tl;dr
What is the R code that takes the keras history form and produces not the tensorflow/keras plot shown below but the ggplot shown slightly farther below?
Details:
Rstudio has a wrapper for keras:
https://tensorflow.rstudio.com/guide/keras/
When training a model, it displays a plot of the loss and metrics over time. I think it is using plotly. I am not interested in the graph that has these stylings.
You can take the history object an plot it again, and it generates a new plot. If you have 'ggplot2' installed, then it uses ggplot.
I am looking for something like this, the product of ggplot2:
What is the R code that takes the keras history form and produces that ggplot?
I am not looking for the wrapper which is 'plot(history)', but the set of frame manipulations and input commands to ggplot that generate the output. It should contain something of the form'ggplot(history, aes(...)) + ...'

Modify R Graphics in CRAN Contributed Packages

I like using the R package qcc. This is a great package for the quality control professional. The package generates a lot of cool graphics. I know how to modify basic graphs in R with the par() command.
The graphics in the qcc package are somewhat unique and I don't always know what elements make up the graphics. How do I determine what elements make up the graphics so I can modify them with the par() commands and arguments. Take this simple cause and effect diagram in the code below. How would I go about modifying line colors, line thicknesses, font, etc? I have no idea how the author constructed this when they developed the package.
library(qcc)
cause.and.effect(cause=list(Measurements=c("Micrometers", "Microscopes", "Inspectors"),
Materials=c("Alloys", "Lubricants", "Suppliers"),
Personnel=c("Shifts", "Supervisors", "Training", "Operators"),
Environment=c("Condensation", "Moisture"),
Methods=c("Brake", "Engager", "Angle"),
Machines=c("Speed", "Lathes", "Bits", "Sockets")),
effect="Surface Flaws")
The following capability analysis should be a little more familiar to the normal R user. How do I modify the three vertical red lines in this graphic? Perhaps I want to use a different color, different line style/thickness, etc. And again, how do I determine what elements make up the graphic so I can modify any particular part of it if I so wish?
library(qcc)
data(pistonrings)
attach(pistonrings)
diameter <- qcc.groups(diameter, sample)
q <- qcc(diameter[1:25,], type="xbar", nsigmas=3, plot=FALSE)
process.capability(q, spec.limits=c(73.95,74.05))

Is there a way to recover a ggplot2 image from a Plotly image?

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)

creating multiple file types while plotting

I would like to produce a series of plots in both high-resolution and low-resolution versions, or stated differently using two different file types (.png and .eps). I'd like to know the best/least repetetive way to do this. I am using the gplot function in sna, and the plot has a custom legend outside the plot area. I wrote a function something like this:
library(sna)
plotfun <- function(net){
png("test.png",width=800)
p <- gplot(net)
par(xpd=T)
legend(max(p[,1])+1,max(p[,2]),legend=letters[1:10],title="custom legend")
dev.off()
seteps()
postscript(test.eps)
#repeat all the plotting commands, which are much longer in real life
dev.off()
}
#try it with some random data
plotfun(rgraph(10))
This is perfectly functional but seems inefficient and clumsy. The more general version of this question is: if for any reason I want to create a plot (including extra layers like my custom legend), store it as an object, and then plot it later, is there a way to do this? Incidentally, this question didn't seem sna specific to me at first, but in trying to reproduce the problem using a similar function with plot, I couldn't get the legend to appear correctly, so this solution to the outside-the-plot-area legend doesn't seem general.
I would recommend generate graphs only in Postscript/PDF from R and then generate bitmaps (e.g. PNG) from the Postscript/PDF using e.g. ImageMagick with -density parameter (http://www.imagemagick.org/script/command-line-options.php#density) set appropriately to get desired resolution. For example
convert -density 100 -quality 100 picture.pdf picture.png
assuming picture.pdf is 7in-by-7in (R defaults) will give you a 700x700 png picture.
With this approach you will not have to worry that the picture comes out formatted differently depending which R device (pdf() vs png()) is used.

Resources