Thanks for the proposition. As you see bellow, par("usr") is the same before and after the points() (the full code is bellow):
....
> par("usr")
[1] -0.2500000  1.2500000 -0.1666667  1.1666667
> # if you remove this points() function, axis will show nothing.
>
> points(1.5, 1.5, type="p")
> p2 <- par(no.readonly=TRUE)
> par("usr")
[1] -0.2500000  1.2500000 -0.1666667  1.1666667
...

I can reproduce it in Ubuntu and MacosX R Gui and Rstudio (R 3.4.1).

Marc

Here is the code:
library(fields)
par(mar=c(5,4.5,4,7))
D <- matrix(c(10, 20, 25, 30, 12, 22, 32, 35, 13, 25, 38, 40), nrow=3)

p0 <- par(no.readonly=TRUE)
image.plot(D, col=rev(heat.colors(128)),bty="n", xlab="Lines",
           ylab="Columns", cex.lab = 0.5, zlim=c(min(D, na.rm=TRUE),max(D,
na.rm=TRUE)),
           las=1, axes=FALSE)
p1 <- par(no.readonly=TRUE)

par("usr")
par("xpd")

# if you remove this points() function, axis will show nothing.

points(1.5, 1.5, type="p")
p2 <- par(no.readonly=TRUE)
par("usr")
par("xpd")

##########
axis(1, at=seq(from=0, to=1, length=nrow(D)), labels=0:2, cex.axis=0.5)
axis(2, at=seq(from=0, to=1, length=ncol(D)), labels=0:3, las=1,
     cex.axis=0.5)

identical(p1, p2)




Le 24/07/2017 à 05:17, Jim Lemon a écrit :
Hi marc,
Try:

par("usr")

before and after the call to points and see if it changes.

Jim


On Sat, Jul 22, 2017 at 12:05 AM, Marc Girondot via R-help
<r-help@r-project.org> wrote:
It is known (several discussions on internet) that axis() cannot be used
after fields:::image.plot() (axis() shows nothing).

However, if points(1.5, 1.5, type="p") is inserted before the axis()
finctions, it works.

I have investigated what points(1.5, 1.5, type="p") is doing to allow axis
to work and I don't find a solution. par() options are identical (p1 and p2
are identical).

Has someone a solution ?

Thanks

Marc

library(fields)
p0 <- par(no.readonly=TRUE)
image.plot(D, col=rev(heat.colors(128)),bty="n", xlab="Lines",
            ylab="Columns", cex.lab = 0.5, zlim=c(min(D, na.rm=TRUE),max(D,
na.rm=TRUE)),
            las=1, axes=FALSE)
p1 <- par(no.readonly=TRUE)

# if you remove this points() function, axis will show nothing.

points(1.5, 1.5, type="p")
p2 <- par(no.readonly=TRUE)

##########
axis(1, at=seq(from=0, to=1, length=nrow(D)), labels=0:2, cex.axis=0.5)
axis(2, at=seq(from=0, to=1, length=ncol(D)), labels=0:3, las=1,
cex.axis=0.5)

identical(p1, p2)

______________________________________________
R-help@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@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.

Reply via email to