[R] graphic device Windows tickmarks

Christian Brandstätter bran.chri at gmail.com
Tue May 31 13:57:51 CEST 2016


Hi,

thank you for your answer. To tackle down the problem, I tried this 
(modified from your code):

thickticks <- c(0,60,130,210,290,370,450,530,610,690,770,850,930)

png("test.png",width=864,height=834,res=150)
plot(seq(0,1000),rep(10,1001),xaxt="n")
axis(1,seq(0,1000,by=10),at=seq(0,1000,by=10),tick=TRUE)
axis(1, at = thickticks, labels=FALSE, las = 1,lwd.ticks=2)
dev.off()

x11()
plot(seq(0,1000),rep(10,1001),xaxt="n")
axis(1,seq(0,1000,by=10),at=seq(0,1000,by=10),tick=TRUE)
axis(1, at = thickticks, labels=FALSE, las = 1,lwd.ticks=2)

On my machine the x-axis-labels differ.
In the test.png the labels are 0,70,170,...
In the x11 window they are the same values as in the thickticks-vector.
Why? I tried to play with different resolution values, this didn't help.

Best, Christian


Am 31.05.2016 um 08:17 schrieb Duncan Mackay:
> Hi
>
> Without looking at the help guide I think there are restrictions on
> resolution
> and just in case of unit problems I worked in the default units
>
>> png("test.png",units="in",width=12,height=12,res=300)
> Error in png("test.png", units = "in", width = 12, height = 12, res = 300) :
>
>    unable to start png() device
> In addition: Warning messages:
> 1: In png("test.png", units = "in", width = 12, height = 12, res = 300) :
>    unable to allocate bitmap
> 2: In png("test.png", units = "in", width = 12, height = 12, res = 300) :
>    opening device failed
>> 12*72
> [1] 864
>> png("test.png",width=864,height=834,res=150)
>> plot(seq(0,1000),rep(10,1001),xaxt="n")
>> axis(1,seq(0,1000,by=10),at=seq(0,1000,by=10),tick=TRUE)
>> axis(1, at = thickticks, labels=FALSE, las = 1,lwd.ticks=2)
>> dev.off()
> Check ?postscript and the options as eps and pdf require different
> arguments.
>> postscript("test.eps", paper = "special", width = 12,height = 12)
>> plot(seq(0,1000),rep(10,1001),xaxt="n")
>> axis(1,seq(0,1000,by=10),at=seq(0,1000,by=10),tick=TRUE)
>> axis(1, at = thickticks, labels=FALSE, las = 1,lwd.ticks=2)
>> dev.off()
>> pdf("test.pdf", paper = "special", width = 12,height = 12)
>> plot(seq(0,1000),rep(10,1001),xaxt="n")
>> axis(1,seq(0,1000,by=10),at=seq(0,1000,by=10),tick=TRUE)
>> axis(1, at = thickticks, labels=FALSE, las = 1,lwd.ticks=2)
>> dev.off()
> All the above work for me on Win 7 32
>
> platform       i386-w64-mingw32
> arch           i386
> os             mingw32
> system         i386, mingw32
>
> Similar to the above has worked on Win 64
>
> Regards
>
> Duncan
>
>
> Duncan Mackay
> Department of Agronomy and Soil Science
> University of New England
> Armidale NSW 2351
> Email: home: mackay at northnet.com.au
>
>
> -----Original Message-----
> From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Christian
> Brandstätter
> Sent: Tuesday, 31 May 2016 05:24
> To: r-help at r-project.org
> Subject: [R] graphic device Windows tickmarks
>
> Dear List,
>
> I discovered an issue; when plotting (base) in R, the tickmark-labels
> are slightly off (Windows machine).
>
> Thus, when saving the plot in R with x11() and dev(...) the
> plot-tickmarks shift, see the example below.
>
> Session Info:
>
> R version 3.2.3 (2015-12-10)
> Platform: x86_64-w64-mingw32/x64 (64-bit)
> Running under: Windows 7 x64 (build 7601) Service Pack 1
>
> With savePlot it works, but the graph quality is not as nice. Am I
> missing something here?
>
>
> Example:
> thickticks <-
> c(0,40,90,140,200,260,320,380,440,500,560,620,680,740,800,860,920,980)
>
> x11(width=12,height=12)
> plot(seq(0,1000),rep(10,1001),xaxt="n")
> axis(1,seq(0,1000,by=10),at=seq(0,1000,by=10),tick=TRUE)
> axis(1, at = thickticks, labels=FALSE, las = 1,lwd.ticks=2)
>
> # plots
> dev.print(device=png,"test.png",units="in",width=12,height=12,res=500) #
> won't display prop.
> dev.print(device=postscript,"test.eps",width=12,height=12)  # won't
> display prop.
> dev.print(device=pdf,"test.pdf",width=12,height=12)  # won't display prop.
> savePlot("test_2.png",type="png") # displays prop.
>
> ______________________________________________
> 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.
>



More information about the R-help mailing list