[R] cutting barplots at e.g. 50%
siim at obs.ee
Mon Mar 18 09:54:17 CET 2002
I have not noticed any reply to your question (perhaps my fault), so I
suggest a workaround.
On Fri, 15 Mar 2002, Jan Malte Wiener wrote:
|i want to plot percentage values using barplot. everything works fine so
|far. giving a chance level of 50% i want to plot only the area above 50
|i can of course cut using ylim=c(50,100) but this does not work
|properly since i also see some of the area below 50%.
Actually, it seems strange for me that R (1.4.0) draws bars outside the plot
are. But you can explicitly subtract 50 and then choose either the result
or 0. To avoid the axis showing values 0..50, you should draw the axis
yourself using axis and labels where you have added 50.
A following example worked for me:
proc <- runif(10,0,100)
lbl <- as.character(formatC(proc, digits=4))
height <- pmax(proc - 50, 0)
spread <- range(height)
axis(2, at=pretty(spread), labels=as.character(pretty(spread) + 50))
You can also consider using
but I do not think that is what you want.
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
More information about the R-help