[R] grid lines aligned on each ticks with a log scale

Duncan Murdoch murdoch at stats.uwo.ca
Sat Mar 20 14:54:23 CET 2010


On 20/03/2010 7:35 AM, Duncan Murdoch wrote:
> On 20/03/2010 6:38 AM, Benoit Boulinguiez wrote:
>> Hi all,
>>  
>> for publication purpose I must provide a graph with grid lines aligned with
>> each tick mark.
>> Thing is that the graph has a log scale on the x-axis.
>> I looked at the grid() and par() documentation but still don't figure out
>> how to get it done.
>>  
>>  
>> simple example
>>  
>> plot(seq(1,9), log="x", panel.first=grid())
>>  
>> how to get lines at x = 2 and 5 on the graph?
> 
> Use abline instead of grid for fine tuning:
> 
> plot(seq(1,9), log="x", panel.first=abline(v=c(1,2,5),h=c(2,4,6,8), 
> lty=3,col="gray"))

or more simply, just use equilogs=FALSE in the grid call:

plot(seq(1,9), log="x", panel.first=grid(equilogs=FALSE))

Duncan Murdoch

> 
> Duncan Murdoch
> 
>> Of course the option "nx" in grid() is not valid, as it does not align the
>> grid lines with the ticks in a log scale...
>>  
>> Thanks for giving a hand.
>>
>> Regards/Cordialement
>>
>> -------------
>> Benoit Boulinguiez
>> Ph.D student
>> Ecole de Chimie de Rennes (ENSCR) Bureau 1.20 
>> Equipe CIP UMR CNRS 6226 "Sciences Chimiques de Rennes"
>> Avenue du Général Leclerc 
>> CS 50837 
>> 35708 Rennes CEDEX 7 
>> Tel 33 (0)2 23 23 80 83
>> Fax 33 (0)2 23 23 81 20
>>  <http://www.ensc-rennes.fr/> http://www.ensc-rennes.fr/ 
>>
>>  
>>
>> 	[[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.
> 
> ______________________________________________
> 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