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)
Related
When I use corrplot::corrplot() to plot a correlation matrix, the bottom label (1) on the y-axis is half cut off, because the bottom of the plot is at the very bottom of the plotting area, and the 1 is centered on the bottom axis. I'd like to use the plot for publication. How do I give a bit more space at the bottom so that this bottom y-axis label is not cut off?
Thanks in advance for the plot and for help with the above. This is a very nice plot except for the above issue.
Larry Hunsicker
Although no reproducible example was provided, we can show here a generic example of how to deal with this. Here a corrplot, in which the bottom label on the color scale is cut off:
M = cor(mtcars)
corrplot(M)
We can solve this by increasing the margin size using mar parameter in corrplot, to give enough space around the figure for labels. We also need to specify par(xpd=TRUE) to allow labels to be printed within the margin areas. Note that the behaviour of corrplot with respect to graphical parameters is somewhat inconsistent. Some parameters need to be specified in a par statement preceding corrplot, otherwise they are not respected if specified within the corrplot statement itself. Other parameters only work if they are specified within the corrplot statement. ?corrplot will tell you which graphical parameters get over-ridden by default values if not specified in corrplot - these are the ones that will have to be specified inside corrplot.
par(xpd=TRUE)
corrplot(M, mar = c(2, 0, 1, 0))
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
I am trying to include two plot in a single window using mfrowin par().
something like this
x=1:10
y=seq(10,100,10)
z=seq(100,1000,100)
par(mfrow=c(2,1))
par(mar=c(0.2,4.1,4.1,2.1))
plot(x,y,xaxt="n",xlab=NA)
par(mar=c(4.1,4.1,0.2,2.1))
plot(x,z)
which gives
Now let's say I want to adjust the height of second plot as small as half the height of the first plot. How can I do it? I was trying with many par() parameters. But I couldn't find a way.
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.
I have just started playing with the quantmod package. The documentation is however, quite sparse (perhaps understandably, since it is OSS).
I am currently using barChart() which is a nice wrapper around chartSeries() and does most of what I want, but the default chart it produces are not quite what I want. To be specific, I want to tweak the charts produced by barChart() to suit my needs - however, since I am a newbie, I don't know whether my "tweaks" can be provided as options to the wrapper barChart(), or if I need to call chartSeries() directly, with specific arguments.
I have been tearing my hair out trying to do the following:
replace the horrible {start date}/{end date} text in the top right hand of the chart produced by barChart() with text of my own choosing
specify the formating to be used on the X axis (for example, show only the last two digits of the century. i.e. '98, '99, '00, '01 etc)
'Force' both top chart and the bottom chart to have their Y values printed on the left hand side of the chart
Add an aditional series to the bottom chart
Use different up/down colors for the bottom chart (defaults the using the same up/down colors for both top and bottom charts)
Plot just the top chart (no bottom chart)
Specify X axis, Y axis grid line spacings for top chart, for bottom chart
Write the image to an alternative output (e.g. png image or pdf document) instead of the graphics device
Can anyone help with any (or all) of the above?.
This functionality isn't available (patches welcome).
This functionality isn't available (patches welcome).
This functionality isn't available (patches welcome).
See the sparse documentation for ?addTA, specifically the on argument.
Plot the bottom chart as two separate up/down series, using two different colors, or perhaps chartTheme.
Not sure what you mean; just don't plot the bottom chart...
See the sparse documentation for the major.ticks argument to chartSeries. I don't think you can change the y axis grid line spacings, and the x axis spacing will be the same for the top and bottom chart.
See ?png and ?pdf.
To change or remove the bottom chart,
check the TA argument of chartSeries function
(there is an example in the manual);
to change the colours,
check the theme argument
(there is an example in the manual);
to write to a png or pdf file,
use the png or pdf functions,
as with other plotting functions.
To fine-tune the axes and labels, it is probably easier to bypass
chartSeries altogether and plot the data yourself, with base graphics,
lattice or ggplot2.