How to expand your plot so all labels can be seen without overlapping in R - r

I have a plot with 50 categories(states) that show on my X axis, but in my output they are on top of each other. I want my plot to be spread out engough/large enough that there is no overlap and you could determine the state value from the next.
NOTE: i used the coord_flip command, so I know that my X-axis is actually my Y in image and vice versa. I am just wondering what function I would use to fix problem.

You can always change the size of the text via themes(axis.text.x=element_text(size=...))...
But the easy answer here is that your plot will change appearance based on the aspect ratio. When you view in Rstudio, you can adjust the size of your plot and you'll see the rearrangement. Additionally, when you save, the plot, play around in particular to the height and width to get the ratio you want. ggsave('filename.png', width=??, height=??).

Related

Plotting an image next to a ruler using r

What I would like to do is make a series of plots that combine an image with a scale that is related to the height of the image, but is multiplied by a factor.
So far I've been able to make a plot using the following code:
library(imager)
im <- load.image("ZAB17_4.png")
plot(im)
Image is attached here
But what I would like to do is to have the y-axis be scaled by a value:
pixel_size <- 0.0596
I would also get rid of the x-axis. (xaxt="n" doesn't seem to do the trick). Ideally, I would like the Y-axis to be directly adjacent to the image. I've been trying to poke around with scales in the plot function, but haven't found what I need to do this, but I'm sure there is a simple solution.
*Edited to add image. I should note that the goal is really just to add a scale to the image. The pixel size represents the size of each pixel in reality in mm. I basically want to add a ruler along the side of the image. Maybe r is not the best tool for this, but I plan to also plot data taken from the imaged object and plot it alongside.
Any help is appreciated.

How can I specify the exact number of pixels I would like my ggplot to take up?

How do I adjust the overall size of a ggplot?
I'm using Shiny, thus, I'd like to control the size of my plot. I'd like one of my plots to be the size of a postage stamp. And, I'd like the plot next to it to be huge.
From what I can tell, no matter how much I play with scale_x_continuous or xlim or cartesian_coord or whatnot, I'm still stuck with a ggplot that has made up it's own mind on how big it wants to be. I can squish down the amount of ink within the size of the plot, or I can fill up the insides of the plot by using various attributes, but I can't change the number of pixels the plot takes up on my screen.
How can I specify the exact number of pixels I would like my plot to be?
I don't know shiny, but maybe this helps,
library(grid)
print(qplot(1,1), vp=viewport(width=unit(114,"points"), height=unit(1.4,"inch")))

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.

Set maximum width of labels in an ASP.NET Chart

I am using the .NET 4 Chart control to create a bar chart. I have labels listed along the left axis (I believe this is the y-axis, I may be wrong). I want to set the maximum width that this axis can be. Currently, I have some labels that are really large. Ideally, I would like to truncate them. However, I cannot figure out how to do either of these.
Can someone tell me how to set the maximum width used by the labels in a Chart? Is it possible to truncate the labels so that if they are larger than the alloted space a "..." appears?
Thank you
I think below code helps to truncate x-axis width. check out something similar to this.
Chart1.Series("Series1")("PixelPointWidth") = "35"

How to center an R plot after removing axis labels

I'm working on visualizing a matrix in R (almost exactly like http://reference.wolfram.com/mathematica/ref/MatrixPlot.html), and I've been using
image(<matrix>,axes=FALSE)
to draw the picture. However, I noticed that with the y-axis turned off, the plot isn't centered--the space is still there for the axis ticks + label. I can finagle some centering with
par(oma=c(0,0,0,2.5))
but this seems inefficient and error-prone (if my matrix were to change dimensions/become non-square). Is there a better way to force the graphic to center?
Reference image http://img694.imageshack.us/img694/9891/metropolis.png
The right hand margin is significantly smaller than the left.
Does
par(mar=c(5,2,4,2))+0.1
help?

Resources