Featured post
graph - R: gplots, barplots: how to fix bar width independent of paper setting? -
i use gplots package output barplots. use inside for-loop, rest of code omitted make more clear:
library("gplots") pdf(file = "/users/tim/desktop/pgax.pdf", onefile = true, paper = "special") par(mfrow = c(4,2)) #figures arranged in 2 rows , 2 columns par(las=2) #perpendicular labels on x-axis barplot2(expression,ylab = expression(expression),main = graph.header, cex.names =0.85, beside = true, offset = 0, xpd = false,axis.lty = 0, cex.axis = 0.85, plot.ci = true,ci.l = expression - sd.value, ci.u = expression + sd.value, col = colors,width = 1,names.arg = c(etc))
now when specify papersize @ a4, , print out in 2 columns bars made fill full space assigned. if have few bars in each graws, width big compared height. know should using xlimit , width
= amongst , perhaps aspect ratio?, can't results wanted. , unconvenient way specify height , width output of paper, , manually adjust number of bars in plots each time. doesnt seem appropiate. know convenient way fix width bars in plots?
all appreciated!
although bar plots wide bars can silly, wide bar plot few narrow bars in sillier. leaves specifying width of plot (via width
argument pdf
).
it may prettiest keep plots same size, in case give width
fixed value. if want narrower plots when there less bars, need line of code like
plot_width <- 3 + 0.5 * nlevels(x_variable)
- Get link
- X
- Other Apps
Comments
Post a Comment