Re: [R] How to break an axis?

2005-05-25 Thread Bjørn-Helge Mevik
What about simply using a log scale on the y axis? I.e. plot(..., log=y)

-- 
Bjørn-Helge Mevik

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] How to break an axis?

2005-05-24 Thread joerg van den hoff

Bo Peng wrote:

Dear list,

I need to plot four almost horizontal lines with y-values around
1,3,4, 400. If I plot them directly, the first three lines will be
indiscernible so I am thinking of breaking y-axis into two parts, one
with range (0,5), another (395,400). Is there an easy way to do this?

I can think of two ways: 
1. use two plots and draw axes manually. The plot margins, are however

difficult to adjust.
2. use one plot, adjust y-values of the lines and draw y-axis
manually. But, how would I break y-axis and add separation symbols
*on* yaxis? (By separation symbol, I mean something like
--//--

Many thanks in davance.
Bo

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


maybe something like

matplot(1:10, rep(1,10)%o%c(1,3,4), col=1:3, ylim = c(0,20), type='b')
par(new=T)
matplot(1:10, rep(400,10),axes=F,ann=F, col=4, ylim = c(0,400),type='b')
axis(4)
legend(par('usr')[2], par('usr')[4], bg='white',   xjust=1, c('left 
axis', 'left axis', 'left axis', 'right axis'),col=1:4,

   pch=as.character(1:4))


solves your problem (double y-axis instead of splitting the axis).

joerg

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] How to break an axis?

2005-05-24 Thread Jim Lemon

Bo Peng wrote:

Dear list,

I need to plot four almost horizontal lines with y-values around
1,3,4, 400. If I plot them directly, the first three lines will be
indiscernible so I am thinking of breaking y-axis into two parts, one
with range (0,5), another (395,400). Is there an easy way to do this?

I can think of two ways: 
1. use two plots and draw axes manually. The plot margins, are however

difficult to adjust.
2. use one plot, adjust y-values of the lines and draw y-axis
manually. But, how would I break y-axis and add separation symbols
*on* yaxis? (By separation symbol, I mean something like
--//--


Hi Bo,

Tom Mulholland has already pointed out that the plotrix package has an 
axis.break() function that will draw the break symbol. Your problem is a 
combination of plotting two disparate sets of data and getting the 
y-axis right. The following is one way to do it, just be careful that 
the ylim= and labels= arguments match up.


y1-1+rnorm(10)/5
y2-3+rnorm(10)/5
y3-4+rnorm(10)/5
y4-397+rnorm(10)/5
library(plotrix)
plot(y1,ylim=c(0,10),axes=FALSE,main=Big range plot,ylab=Y values)
points(y2)
points(y3)
box()
axis(2,at=c(1,2,3,4,6,7,8,9),labels=c(1,2,3,4,396,397,398,399))
axis.break(2,5)
par(new=TRUE)
plot(y4,ylim=c(390,400),axes=FALSE,main=,ylab=,xlab=)

Jim

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] How to break an axis?

2005-05-24 Thread Bo Peng
 Tom Mulholland has already pointed out that the plotrix package has an
 axis.break() function that will draw the break symbol. Your problem is a
 combination of plotting two disparate sets of data and getting the
 y-axis right. The following is one way to do it, just be careful that
 the ylim= and labels= arguments match up.
 
 y1-1+rnorm(10)/5
 y2-3+rnorm(10)/5
 y3-4+rnorm(10)/5
 y4-397+rnorm(10)/5
 library(plotrix)
 plot(y1,ylim=c(0,10),axes=FALSE,main=Big range plot,ylab=Y values)
 points(y2)
 points(y3)
 box()
 axis(2,at=c(1,2,3,4,6,7,8,9),labels=c(1,2,3,4,396,397,398,399))
 axis.break(2,5)
 par(new=TRUE)
 plot(y4,ylim=c(390,400),axes=FALSE,main=,ylab=,xlab=)
 

Thank you very much for the real code. I did almost exactly the same
thing. I did not know the new=TRUE option so I used lines(y4-offset,
...). Anyway, the results are the same.

The left-right-axes solution is also very interesting. It is actually
better if the ranges of lines differ significantly.

Thank you again for the help.
Bo

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] How to break an axis?

2005-05-23 Thread Bo Peng
Dear list,

I need to plot four almost horizontal lines with y-values around
1,3,4, 400. If I plot them directly, the first three lines will be
indiscernible so I am thinking of breaking y-axis into two parts, one
with range (0,5), another (395,400). Is there an easy way to do this?

I can think of two ways: 
1. use two plots and draw axes manually. The plot margins, are however
difficult to adjust.
2. use one plot, adjust y-values of the lines and draw y-axis
manually. But, how would I break y-axis and add separation symbols
*on* yaxis? (By separation symbol, I mean something like
--//--

Many thanks in davance.
Bo

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] How to break an axis?

2005-05-23 Thread Mulholland, Tom
I think you may wish to look at the plotrix package, assumming that you have 
taken care of the issues involved in breaking an axis and that your plots don't 
result in misleading information.

I think to use the axis break you would have to calculate your own labels and 
rescale the data, as it looks as if the break is just the cosmetics component.

This is also the topic of many posts on the list so you might want to search 
the list for break and axis to see other responses to this issue.

Tom

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] Behalf Of Bo Peng
 Sent: Tuesday, 24 May 2005 10:00 AM
 To: r-help@stat.math.ethz.ch
 Subject: [R] How to break an axis?
 
 
 Dear list,
 
 I need to plot four almost horizontal lines with y-values around
 1,3,4, 400. If I plot them directly, the first three lines will be
 indiscernible so I am thinking of breaking y-axis into two parts, one
 with range (0,5), another (395,400). Is there an easy way to do this?
 
 I can think of two ways: 
 1. use two plots and draw axes manually. The plot margins, are however
 difficult to adjust.
 2. use one plot, adjust y-values of the lines and draw y-axis
 manually. But, how would I break y-axis and add separation symbols
 *on* yaxis? (By separation symbol, I mean something like
 --//--
 
 Many thanks in davance.
 Bo
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! 
 http://www.R-project.org/posting-guide.html


__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html