[R] Plot and polygon in log scale

Peter Ehlers ehlers at ucalgary.ca
Sat Dec 3 02:29:28 CET 2011

On 2011-12-02 13:03, Santosh wrote:
> Dear Experts,
> When using "plot" and "polygon", I can change the density and angle of the
> shaded area lines when plotting is done in regular scale. It does not seem
> to work in 'log' scale. Any suggestions would be highly appreciated!
> below is an example:
> plot(1:10,c(1:10)^2*20,log="y")
> polygon(c(3:7,7:3),c((3:7)^2*20,c(7:3)^2*10),col='grey',angle=45,dens=30)
> Warning message:
> In polygon.fullhatch(xy$x[start:(end - 1)], xy$y[start:(end - 1)],  :
>    cannot hatch with logarithmic scale active
> Regards,
> Santosh

It looks like density is not implemented for log scales. (There is a
comment in the source file.) Perhaps a note in the help file might be
useful, but I would think that nowadays most users would want colour
or shades of gray anyway.

Of course, you can always do the logging on the data before plotting.
You'll just have to use the axis() function to print appropriate axis

Peter Ehlers

> 	[[alternative HTML version deleted]]
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list