multiple plots in r, a, b, c, d with lines and curves - r

I have some pretty nice plots that I want to present in a report, but I would like to have multiple plots with one common legend, title and caption. The problem is the lines in the plots. So far I have made a plot and added lines or curves from one or several binomial models. These curves/lines exist in different data.frames, but they can fit in the same plot because they have the same parameters and lengths.
I have tried to make a plot where I add all the lines at the same time as the plot is being created but then only the lines show up and i got a lot of errors.
So when i create a plot with lines i do like this:
plot(Spruce,Leaves,xlab="Spruce",ylab="Leaves>0")
g=glm(Leaves>0~Spruce,family=binomial,data=1)
g2=glm(Leaves>0~Spruce,family=binomial,data=2)
curve(predict(g,data.frame("Spruce"=x),type="resp"),add=TRUE,col="blue")
curve(predict(g2,data.frame("Spruce"=x),type="resp"),add=TRUE,col="red")
I cannot upload a picture of the plot, but it's nice.
The problem is that I need to present it with several other plots to explain my point and then I would like to do it as one of several a,b,c,d plots.
I have used
par(mfrow=c(2,2))
To have all plots visual at the same time but I would like to name them a,b,c,d and have a common legend, title and mtext.
Any suggestions how to do that?

Related

making a 2x2 plot layout with plots from different platforms

I am trying to make a 2x2 layout of four plots. I have two plots from ggplot(i.e., ggbiplot) and two plots from heatmap2. My dream was to put them all together in one page. I have followed Claus Wilkes cowplot tutorials. They work fine with ggplot-style plots and base plots (i.e., plots make with the plot command). However, moving to heatmap2 making the desired layout does not result in any 2x2 plot, only single plots.
Appreciate suggestions.
Thanks,
jahn

How can I create a panel layout with grouped plots?

I was wondering if you could help me with something.
I'm currently writing some papers with regression analyses (and scatter plots with fitted lines). I'd like to merge all my plots into a single panel as shown.
I've already stacked some plots using grid.arrange from gridExtra (which go in box A), but I have no clue how to:
Create boxes A, B, C, (...), each with its own letter on the top-left corner. Each box contains stacked plots (2 or 3 rows depending on the # of models, with all plots for a single model on the same row) linear regression plots.
Place color labels on top of the boxes (e.g Social Cognition and Moral Judgement)
Place vertical text (which would serve as the Y label) such as Risk Perception and Impact Estimation
Thank you very much
This is the referenced layout
You can plot multiple charts within the same chart area. You can do this with the standard graphics functions by setting the mfcol parameter for a device. For example, to plot six figures within the plot area in three rows of two columns, you would set mfcol as follows:
par(mfcol=c(3, 2))
Each time a new figure is plotted, it will be plotted in a different row or column within the device, starting with the top-left corner.
So you can use plot or ggplot or another plotting package and the plot will be added to the layer.

Box plots, plots in octave

I'm new to Octave, so there are many confusing things for me, and I've never done computer programming before so most of the language is also confusing.
I have sets of data c_o, m_o, y_o, k_o as 144 x 1 matrices (column vectors?)
Box plots
Using examples I found online, I wrote this:
axis ([0,5]);
boxplot (c_o, m_o, y_o, k_o);
set(gca (), "xtick", [1,2,3,4], "xticklabel", {"cyan", "magenta", "yellow", "key"});
However, it results in an error
Boxplot.m: grouping vector may only be passed as second arg
I have no idea what this means.
Plots
I'm trying to figure out how to plot multiple data sets with different colors.
For example,
figure (1); plot (c_o , "c");
works perfectly fine.
However, I'd like to remove the horizontal axis, change the horizontal axis from [0,200] to [0,150] , and plot multiple sets of data on the same plot (not multiple plots in the same figure, but the different data on the same set of axis). I haven't been able to find out how, though.
For the record, I do know that there are probably other programming languages more suited for statistical analysis; it just so happens that my first use of this happened to be statistical in nature.

Plotting in R multiple graphs without spaces

I’m aware that how to plot multiple graphs in a same window has been solved already and it’s pretty straight forward. But I can’t find how to remove the space between the different graphs.
I use this script to arrange these three graphs in the same window:
mat<-(matrix(1:3,ncol=3))
layout(mat,widths = rep.int(1, ncol(mat)),heights = rep.int(1,nrow(mat)),respect =F)
layout.show(n = 3)
With this script I can generate this graph:
These three violin plots where obtained from a large dataset. I don’t publish the script to get them since I think is not relevant for the purpose of this question.
As you can see this figure can be improved. First the labels at the x-axis are cut from the figure, I don’t know why this is happening. Also I want to remove the space between the three plots. Thanks!

R: Lattice Plots/Wireframe : Splitting Panel Plots into single plots

How can I force wireframe panels to produce single plots instead of one panel plot/grid plot? The reason is that if I have to produce a Sweave/ Pdf File the original wireframe plot, which R produces and which you can see in my other post
Faceted Lattice Plots in R, e.g., wireframes: How to remove strips and add 1-Line subtitles.
will look very small, especially if I have many many single wireframe plots. I can handle single plots more easily in Sweave.
Lattice allows you to specify the number of columns and rows for the plots which then spill over onto adjacent pages if a multi-page device is used:
pdf("nine.pdf", onefile=TRUE, paper="special")
wireframe(pred~Sepal.Width+Petal.Width|interaction(Species,Petal.Length),
pd, drape=FALSE,scale=list(arrows=FALSE), subset=(Species=="setosa"),
layout=c(1,1,9))
dev.off()
On the console device they create new plots which stack up in the plot device and you can "scroll-back" with keystrokes that may vary depending on your unstated OS. The eps format is accessible using directions in ?ps.

Resources