[R] plotting barplot in log scale
mschwartz at medanalytics.com
Thu Aug 29 02:28:37 CEST 2002
> Does anyone know how to get barplot to plot in log scale? I tried:
> barplot(Mx, log="y", besides=F), where Mx is a 2 by 31 matrix to be
> R complains: Error in plot.window(xlim, ylim, log = "", ...) :
> formal argument "log" matched by multiple actual arguments
> I know there's nothing wrong with the rest of the arguments because if
> took out log="y", it plots fine.
> I'm using version 4.1 on Linux.
The problem that you are having is that barplot.default() (the method
used by barplot() ), explicitly calls the following if "plot = TRUE":
plot.window(xlim, ylim, log = "", ...)
Note that the log argument is passed to plot.window() in such a fashion
as to negate the value you have when you call barplot(). This is the
cause of the error that you are getting since the log argument is being
passed as both "" and "y" from your initial call.
The "cleanest" approach might be to modify the code for
barplot.default() to enable you to pass a log argument and create a new
barplot function using the modified code. You'd also have to do some
checking on the y-axis limits, etc.
Alternatively, you could create the plot piece-meal by using
plot.window() to create the plotting region with a y-axis log scaled
with region limits that you specify and then draw the bars using rect().
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