Paolo Rossi
2011-Jul-08 12:20 UTC
[R] Vertical Labels in plot graph - normally working fine but not on this graph
Hello, I wonder if someone can elaborate on why in the first graph I am able to set labels vertical to the x-axis but not in the second. I tried to select the window but it didnt really help. Many Thanks Paolo ExtAvgCWV = rnorm(200) ExtAvgDemand = rnorm(200) ExtGasDays = seq(from = as.Date("2010-8-4", "%Y-%m-%d"), along.with ExtAvgCWV, by = "days") plot(ExtAvgCWV, ann=FALSE, xaxt="n", yaxt="n" ) tickplaces <- seq( from = 1, by = 21, to = length(ExtGasDays)) Labels = ExtGasDays[tickplaces] axis(side =1 , at = tickplaces, labels = Labels) par(las = 3) windows() plot(ExtAvgDemand, ann=FALSE, xaxt="n", yaxt="n" ) #dev.set(which = 4) axis(side =1 , at = tickplaces, labels = Labels) par(las = 3) [[alternative HTML version deleted]]
Berry Boessenkool
2011-Jul-08 12:43 UTC
[R] Vertical Labels in plot graph - normally working fine but not on this graph
Hey Paolo, you should specify las BEFORE you send the axis command. It would also be good to set greater margins, this needs to be set before the entire plot, thus in following order: par(las = 3, mar=c(6,2,2,2)) plot(ExtAvgCWV, ann=FALSE, xaxt="n", yaxt="n" ) axis(side =1 , at = tickplaces, labels = Labels) If you only want to use las, you can also use this as an arument in the axis function. HTH, Berry ------------------------------------- Berry Boessenkool Potsdam -------------------------------------> Date: Fri, 8 Jul 2011 13:20:51 +0100 > From: statmailinglists at googlemail.com > To: r-help at r-project.org > Subject: [R] Vertical Labels in plot graph - normally working fine but not on this graph > > Hello, > > I wonder if someone can elaborate on why in the first graph I am able to set > labels vertical to the x-axis but not in the second. > > I tried to select the window but it didnt really help. > > > Many Thanks > > Paolo > > > > ExtAvgCWV = rnorm(200) > ExtAvgDemand = rnorm(200) > ExtGasDays = seq(from = as.Date("2010-8-4", "%Y-%m-%d"), along.with > ExtAvgCWV, by = "days") > plot(ExtAvgCWV, ann=FALSE, xaxt="n", yaxt="n" ) > tickplaces <- seq( from = 1, by = 21, to = length(ExtGasDays)) > Labels = ExtGasDays[tickplaces] > axis(side =1 , at = tickplaces, labels = Labels) > par(las = 3) > > windows() > plot(ExtAvgDemand, ann=FALSE, xaxt="n", yaxt="n" ) > #dev.set(which = 4) > axis(side =1 , at = tickplaces, labels = Labels) > par(las = 3) > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > 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.
Alexander Engelhardt
2011-Jul-08 13:00 UTC
[R] Vertical Labels in plot graph - normally working fine but not on this graph
Hey, from what I see, you try to use the par(las=3) function after the plot command. You should use it before it, though. Somewhat liek this: ExtAvgCWV = rnorm(200) ExtAvgDemand = rnorm(200) ExtGasDays = seq(from = as.Date("2010-8-4", "%Y-%m-%d"), along.with ExtAvgCWV, by = "days") op <- par(las = 3) plot(ExtAvgCWV, ann=FALSE, xaxt="n", yaxt="n" ) tickplaces <- seq( from = 1, by = 21, to = length(ExtGasDays)) Labels = ExtGasDays[tickplaces] axis(side =1 , at = tickplaces, labels = Labels) par(op) X11() ## windows() op <- par(las = 3) plot(ExtAvgDemand, ann=FALSE, xaxt="n", yaxt="n" ) #dev.set(which = 4) axis(side =1 , at = tickplaces, labels = Labels) par(op) Am 08.07.2011 14:20, schrieb Paolo Rossi:> Hello, > > I wonder if someone can elaborate on why in the first graph I am able to set > labels vertical to the x-axis but not in the second. > > I tried to select the window but it didnt really help. > > > Many Thanks > > Paolo > > > > ExtAvgCWV = rnorm(200) > ExtAvgDemand = rnorm(200) > ExtGasDays = seq(from = as.Date("2010-8-4", "%Y-%m-%d"), along.with > ExtAvgCWV, by = "days") > plot(ExtAvgCWV, ann=FALSE, xaxt="n", yaxt="n" ) > tickplaces<- seq( from = 1, by = 21, to = length(ExtGasDays)) > Labels = ExtGasDays[tickplaces] > axis(side =1 , at = tickplaces, labels = Labels) > par(las = 3) > > windows() > plot(ExtAvgDemand, ann=FALSE, xaxt="n", yaxt="n" ) > #dev.set(which = 4) > axis(side =1 , at = tickplaces, labels = Labels) > par(las = 3)