Change the size/dimension of graph in ggplot2 R - r

How do I change the size of a plot made with ggplot2?
My actual issue is: I'm using ggplot2 R to plot data in Ipython, and I have a horizontal barplot with a lot of bar to be displayed, so I want to increase the height of the graph so I can see it better.
Thanks a lot!

Maybe you should check option coord_cartesian(xlim=c(x,y), ylim=(x,y)) to rescale your graph, but if the output in Ipython is not in the demand size I think thisi rather Ipython figure height/width options-like question

Related

What command to use to zoom out a plot in R?

I have a barplot and the names for the bars are all vertical on the x-axis. However, the names are fairly long and don't show completely in the plot. Is there any command I can use to zoom out the plot? I have already tried the package "zoom" and zm() but it doesn't work.
One way to handle this is to increase the margin size before plotting. Here is a simple example. First, to show the problem:
LongNames = c("RatherLongName_1", "RatherLongName_2",
"RatherLongName_3", "RatherLongName_4")
barplot(1:4, names.arg=LongNames, las=3)
Then with the margins adjusted.
par(mar=c(10,4,4,2))
barplot(1:4, names.arg=LongNames, las=3)

How to resize a plot (not the window) in R?

Hopefully a simple question for the community tonight:
I'm creating a boxplot with particularly long xlabels, which are rotated. The issue I'm running in to is that regardless of what plot window size I set using
dev.new(width=999, height=999)
The plot itself stretches to fill the window,and the x labels are chopped.
How do I resize the plot itself, regardless of window size?
My current plotting code is:
boxplot(mean_density~Landscape*category,ylab="Mean density",las=2,data=data1C)
The reason the X labels are so long is because of that landscape*category piece.
Thanks in advance!!
Thanks to MrFlicks quick response I managed to track down the mar() function within par().
boxplot(mean_density~Land.Cat,ylab="Mean density",las=2,data=data1C)
generated:
whereas
boxplot(mean_density~Land.Cat,ylab="Mean_density",las=2,par(mar=c(9,4,1,4)),data=data1C)
generates:
Figured it'd be an easy one:-D thanks for the help!

Aesthetics for graphs in R WITHOUT using ggplot

I looked for the easthetics to make the histogram look better in my R code, nonetheless I was wondering if I could change the size of the bins or maybe the margin or put a color background in the plot WITHOUT using ggplot.
Thank you.

qcc pareto.chart: bars are squashed - how to adjust the y axis?

I've produced a pareto.chart using the QCC package in R. In the default plot, the Y axis is scaled too large & for that reason the bars are too small. Most of the plot is wasted to empty white space. I assume this is a result of the long tail (right-skew) in the data ?
How is it possible to re-scale the Y-Axis so that the bars of the chart will be taller and more prominent (and differences between the bars more visible) ?
This is my first question and I can't post images yet. Please follow the link to an illustration of the problem:
https://www.dropbox.com/s/t8bwhmoxmwl1aic/pareto-axis.png
Thanks!
Keith
If you type help(pareto.chart) you will see there is an option ylim to specify the limits if the y-axis. If you provide some sample data I could try it out.
Otherwise, try including in your function call
pareto.chart(..., ylim=c(0,10000))
and see if that rescales your y-axis.

plotting points on top of image in R

These days I am extensively using R to scatter plots.
Most of the plotting is concerned with image processing,
Recently I was thinking of plotting the scatter plots over an image.
For example, I want something like this,
The background needs to be filled with my image. With a particular scale.
And I should be able to draw points (co-ordinates) on top of this image ...
Is this possible in R?
If not, do you guys know of any other tool that makes this easy ...
I'm not 100% sure what you have in mind, but I think first you want to load and plot an image in R. You can do that with the ReadImages package:
picture <- read.jpeg("avatar.jpg")
plot(picture)
Then you can do a scatter plot on top of it:
points(runif(50,0, 128), runif(50,0,128))
A step-by-step tutorial to this kind of plotting is in the R-wiki

Resources