[R] Barplot with "Independent" Lines Y axis

Rodrigo Aluizio r.aluizio at gmail.com
Thu Dec 9 17:43:33 CET 2010


Hi list. I'm plotting pluviometric (Rain) data as a barplot, and then adding
the salinity variable to this plot as lines. Obviously as these Y scales are
completely different the salinity appears at the lower part of the graph
extremely compacted. I need to plot the line at the exactly same area of the
barplot but with its own Y axis (at the right), so the salinity can use the
plot area freely. I tried the par(new=T), but it only works for high level
plot functions (not for lines or points).

Below are some example data and the code I'm using:

Month	Rain	Salt
Fev	365.6	13
Mar	235	18
Abr	115.1	18
Mai	47.4	18.75
Jun	112	15
Jul	156.8	17
Ago	66.1	15
Set	149.8	14
Out	167.1	11.5
Nov	269.3	17.5

mp<-barplot(Dados$Rain,names.arg=rownames(Dados),ylab='Pluviosidade
(mm)',width=0.5,ylim=c(0,370),yaxp=c(0,370,10))
lines(mp,Dados$Salt,type='b',pch=19,lty='dotted')

Any ideas?

Thank you for the attention.

Regards

-------------------------------------------------------------------
MSc. Rodrigo Aluizio
Centro de Estudos do Mar/UFPR



More information about the R-help mailing list