Hello, I want to break the y-axis on one of my plots. I read this is possible- but apparently only with the plotrix package that requieres R version 3.6-1? I cannot seem to find that version on the R homepage.. it is a version you have to pay for? Are there any other possebilities to do it (I am currently running (for R version 3.1.2) ) Thank you, Eike [[alternative HTML version deleted]]
The current version of R is 3.2.3 and is available on the website. You should update. The current version of plotrix is 3.6-1 -----Original Message----- From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Eike Marie Thaysen Sent: Tuesday, February 23, 2016 11:00 AM To: r-help at r-project.org Subject: [R] axis break in R Hello, I want to break the y-axis on one of my plots. I read this is possible- but apparently only with the plotrix package that requieres R version 3.6-1? I cannot seem to find that version on the R homepage.. it is a version you have to pay for? Are there any other possebilities to do it (I am currently running (for R version 3.1.2) ) Thank you, Eike [[alternative HTML version deleted]] ______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Hi Eike, I think that plotrix v3.6-1 should run on R v 3.1.2. Jim On Wed, Feb 24, 2016 at 4:11 AM, Federman, Douglas < Douglas.Federman at utoledo.edu> wrote:> > The current version of R is 3.2.3 and is available on the website. You > should update. The current version of plotrix is 3.6-1 > > -----Original Message----- > From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Eike > Marie Thaysen > Sent: Tuesday, February 23, 2016 11:00 AM > To: r-help at r-project.org > Subject: [R] axis break in R > > Hello, > I want to break the y-axis on one of my plots. I read this is possible- but > apparently only with the plotrix package that requieres R version 3.6-1? I > cannot seem to find that version on the R homepage.. it is a version you > have to pay for? Are there any other possebilities to do it (I am currently > running (for R version 3.1.2) ) > Thank you, > Eike > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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 -- To UNSUBSCRIBE and more, see > 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. >[[alternative HTML version deleted]]
Hi Eike,
I didn't know how to do, so it was a nice exercise. Here is a solution
using plot(). I have made a function plot.break(); the name of
parameters of the function are self-explained (I think), but tell me if
you need more explanation.
You can add any parameters of the plot() function.
I have made this function very fast and it is not fully tested. If you
see a problem, do not hesitate to tell me.
Sincerely
Marc
plot.break <- function(x, y, at.cut, at.continue, add.cut,
number.ticks.bottom, number.ticks.up,
min.y, max.y, ...) {
p.plot <- list(...)
p.plot <- modifyList(list(x = x, y=ifelse(y>at.cut,
y-at.continue+add.cut, y),
bty="n", type="p", las=1,
ylim=c(min.y, max.y-at.continue+add.cut),
yaxt="n", xlab="x", ylab="y"),
p.plot)
do.call(plot, p.plot)
y.axis <- c(seq(from=0, to=at.cut, length=number.ticks.bottom),
seq(from=at.cut+add.cut, to=ScalePreviousPlot()$ylim[2],
length=number.ticks.up))
axis(2, at=y.axis,
labels=ifelse(y.axis>at.cut, y.axis+at.continue-add.cut, y.axis),
las=1)
par(xpd=TRUE)
x.left <-
ScalePreviousPlot()$xlim[1]-0.05*ScalePreviousPlot()$xlim["range"]
x.right <-
ScalePreviousPlot()$xlim[1]+0.00*ScalePreviousPlot()$xlim["range"]
polygon(x=c(x.left, x.right, x.right, x.left, x.left),
y=c(at.cut+0.5, at.cut+0.5, at.cut+add.cut-0.5,
at.cut+add.cut-0.5, at.cut+0.5),
col="white", border=NA)
}
x <- 1:10
y <- c(rnorm(5, 10, 5), rnorm(5, 100, 5))
library(HelpersMG)
at.cut <- 20
at.continue <- 60
add.cut <- 5
number.ticks.bottom <- 3
number.ticks.up <- 5
min.y <- 0
max.y <- 120
plot.break(x = x, y=y, at.cut= 20,
at.continue= 60,
add.cut= 5,
number.ticks.bottom= 3,
number.ticks.up= 5,
min.y= 0,
max.y= 120, xlab="Value x")
Le 23/02/2016 11:00, Eike Marie Thaysen a ?crit :> Hello,
> I want to break the y-axis on one of my plots. I read this is possible- but
> apparently only with the plotrix package that requieres R version 3.6-1? I
> cannot seem to find that version on the R homepage.. it is a version you
> have to pay for? Are there any other possebilities to do it (I am currently
> running (for R version 3.1.2) )
> Thank you,
> Eike
>
>