I have a complex layout of plots, say for example
layout(matrix(1:2,nrow=1), widths=c(1,7))
I have drawn earlier plots, and am now working on a particular plot (e.g. working on the code on the plot). I redraw the plot often to see impacts of changing e.g. margins.
How can I avoid that each time I redraw the plot it moves on to the next plot in the layout?
e.g. each time I have to start from the beginning, call dev.off, call layout, plot the earlier plots, and then start again with my plot.
Can I just select which plot in the layout I want to plot? Can I move the "counter" that selects which plot is being plotted next?
Related
I'm using r-markdown to make one pagers. I have all my plots set in place but they do not line up nicely. The plots area is lined up but where the bars start is different for each plot. How can i set it so that it's always lined up? I want to line up the green lines.The start of the plots (maroon line) is always in line.
NB! The two plots are made separately from one another as they use different data.
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.
Sorry if this question has already been answered but I can't find a solution.
I have a data frame which is imported from a .csv file. It has four columns. I want to plot a 3d scatter plot of the first two columns against the last column using Plotly.
The problem is that for some reason, the scatter plot does not automatically resize its axes to fit the plot space. So in this case I end up with a tall thin plot. The weird thing is that if I do an example with some random numbers, I don't get this problem.
Can anyone help me to get my scatter plot to fit to the window?
My data can be found at https://www.dropbox.com/s/ojwrezjker33x2b/Data.csv?dl=0
Basically I want to do:
library(plotly)
X<-read.csv("Data.csv")
plot_ly(x=X[,1],y=X[,2],z=X[,4],type='scatter3d',mode='markers')
And this results in a tall and thin scatter plot (sorry can't post an image cos I am new to the site).
I would like this to be a well-proportioned scatter plot that fits the window.
Thanks for any help.
The default setting for aspectmode is 'auto' and Plotly will try to keep the relative axis lenghts equal.
If you set aspectmode='cube' you should get a plot with identical absolute axes lengths.
plot_ly(x=X[,1],y=X[,2],z=X[,4],type='scatter3d',mode='markers') %>%
layout(scene=list(aspectmode='cube'))
I am plotting a scatter plot in R, however I have many data points and they overlap. I want to have a plot where there no overlaps and maintain a reasonable size of the data . This is the image of the scatter. On the top side is where the data are clustered.
This is the code plot(data2,col="red",pch=21,cex=0.7)
Could you put a reproducible code to check.
One thing you can do is may be increase the space between y axis interval.
I've been working on putting together a broken y-axis histogram, in order to display one very tall bar while not having the other bars invisible. In particular, I would like to be able to control not only what the tics are on the x-axis (they need to show the count bins from the histogram, not just the axes), but also how many tics there are on the x-axis.
This question got me started, though I had to figure out on my own how to use the xtics option in plotrix's gap.barplot to show the histogram bins:
Put a break in the Y-Axis of a histogram
However, I still cannot figure out a way to plot a broken y-axis histogram without having it try to plot a tic for every single bin. Does anybody know a way to do this?