Skip to content

RES: Barplot with "Independent" Lines Y axis

6 messages · Rodrigo Aluizio, Peter Ehlers, Dennis Murphy +1 more

#
Oh sorry. An example say lots more than words. The data below, when
submitted to twoord.plot return the mentioned error. Rain are bars and Salt
lines, the bars appear and the error occurs with the salt data.

Point	Rain	Salt
Fev/03	365.6	13
Mar/03	235	18
Abr/03	115.1	18
Mai/03	47.4	18.75
Jun/03	112	15
Jul/03	156.8	17
Ago/03	66.1	15
Set/03	149.8	14
Out/03	167,1	11.5
Nov/03	269.3	17.5
Dez/03	283.7	
Jan/04	415	1,3
Fev/04	322	8,5
Mar/04	258.7	10.5

-----Mensagem original-----
De: Greg Snow [mailto:Greg.Snow at imail.org] 
Enviada em: quinta-feira, 9 de dezembro de 2010 17:57
Para: Rodrigo Aluizio; 'R Help'
Assunto: RE: [R] Barplot with "Independent" Lines Y axis

Without seeing a reproducible example we cannot be sure, but my guess is
that you are letting twoord.plot set the limits and the function does not
remove missing values, if you specify rylim and or lylim arguments
specifically, then it should not run into the problem you are seeing (I
hope).

If that does not work, then send a small reproducible example (the dput
command is great for the data part) which will help us find the problem.
#
On 2010-12-09 14:22, Rodrigo Aluizio wrote:
If you get an error complaining about needing finite ylim values,
then why not supply them?
This worked for me (after fixing your data which contains
several commas where decimal points are needed) and calling
the data frame 'd':

  with(d,
     twoord.plot(
       lx=1:14, ly=Rain, rx=1:14, ry=Salt,
       lylim=c(0,450), rylim=c(0,20),
       type=c('bar','b')))

(I had to use with(), because the 'data' argument
in twoord.plot seems not to function as intended.)

I have no idea why anyone would want to use a barplot
for the Rain data, but ...

The above should not be taken as an endorsement of
the production of abominable plots (to which, however,
I am becoming inured).

Peter Ehlers
#
On 12/10/2010 08:48 PM, Rodrigo Aluizio wrote:
Hi Rodrigo,
Although I came rather late to this, I might as well show how I did it:

# first I corrected the commas as Peter pointed out
library(plotrix)
par(las=3)
twoord.plot(ly=pluv_sal$Rain,lx=pluv_sal$Salt,mar=c(6,4,4,2),
  xlab="",ylab="Rainfall (mm)",rylab="Salinity",type=c("bar","b"),
  main="Rainfall and salinity",lcol=NA,rcol=2,
  xticklab=pluv_sal$Point,xaxt="n")
par(las=0)
mtext("Month",side=1,at=7,line=3)

You did find a bug in the twoord.plot function, and the next version of 
plotrix will contain one more bug fix, with thanks to you.

Jim
1 day later
#
Well, at least I could help (even if unintentionally), as a
compensation for all the help I got from the list.

Cheers.

Em sexta-feira, 10 de dezembro de 2010, Jim Lemon<jim at bitwrit.com.au> escreveu: