After a long and winding road (sorry but I'm a novice) I get to a final
result which is quite close to what I need;
nevertheless I would like to tweak a little further the xyplot so that I can
get ***for each single panel defined by variable z*** a finer control over:
-the x and y the limits: I would like to be the same for both axes;
-the number of thick marks: again I would like to be same for both axes;
the (general) code snippet here attached does not get this result;
any help for this ?
thank you
#my example
xyplot(y ~ x | z, data=mydata,
aspect="xy",
scales= list(x=list(relation="free", log=10),
y=list(relation="free", log=10)),
prepanel = function(x, y, subscripts) {
list(xlim = c(min(x,y), max(x,y)))
list(ylim= c(min(x,y), max(x,y)))
},
panel = function(x, y ,subscripts,...) {
#panel.xyplot(x, y, xlim = c(min(x,y), max(x,y)), ylim =
c(min(x,y), max(x,y)),...)
panel.xyplot(x, y, ...)
panel.abline(a = 0, b = 1, lty = 2, col ="gray")
panel.text(x, y, labels=mydata$name[subscripts])
},
subscripts=TRUE,
xscale.components = xscale.components.logpower,
yscale.components = yscale.components.logpower
)
in attachment http://r.789695.n4.nabble.com/file/n4511897/my_example.png
my_example.png
--
View this message in context: http://r.789695.n4.nabble.com/xyplot-lattice-fine-control-of-axes-limits-and-thick-marks-with-log-scale-tp4511897p4511897.html
Sent from the R help mailing list archive at Nabble.com.
xyplot lattice fine control of axes limits and thick marks (with log scale)
5 messages · Massimo Bressan, ilai
On Wed, Mar 28, 2012 at 4:21 AM, maxbre <mbressan at arpa.veneto.it> wrote:
After a long and winding road (sorry but I'm a novice) I get to a final result which is quite close to what I need; nevertheless I would like to tweak a little further the xyplot
Without dput(mydata) you are the only one who can do that... so that I can
get ***for each single panel defined by variable z*** a finer control over: -the x and y the limits: I would like to be the same for both axes;
relation='same' in the scales. BTW this is the default, why did you change to 'free' ?
-the number of thick marks: again I would like to be same for both axes;
Most modifications of tick marks, labels and limits are easy through the scales argument. ?xyplot and examples. Best, Elai
the (general) code snippet here attached does not get this result;
any help for this ?
thank you
#my example
xyplot(y ~ x | z, data=mydata,
? ? ? aspect="xy",
? ? ? scales= list(x=list(relation="free", log=10),
? ? ? ? ? ? ? ? ? ?y=list(relation="free", log=10)),
? ? ? prepanel = function(x, y, subscripts) {
? ? ? ? list(xlim = c(min(x,y), max(x,y)))
? ? ? ? list(ylim= c(min(x,y), max(x,y)))
? ? ? },
? ? ? panel = function(x, y ,subscripts,...) {
? ? ? ? #panel.xyplot(x, y, xlim = c(min(x,y), max(x,y)), ylim =
c(min(x,y), max(x,y)),...)
? ? ? ? panel.xyplot(x, y, ...)
? ? ? ? panel.abline(a = 0, b = 1, lty = 2, col ="gray")
? ? ? ? panel.text(x, y, labels=mydata$name[subscripts])
? ? ? },
? ? ? subscripts=TRUE,
? ? ? xscale.components = xscale.components.logpower,
? ? ? yscale.components = yscale.components.logpower
? ? )
in attachment ?http://r.789695.n4.nabble.com/file/n4511897/my_example.png
my_example.png
--
View this message in context: http://r.789695.n4.nabble.com/xyplot-lattice-fine-control-of-axes-limits-and-thick-marks-with-log-scale-tp4511897p4511897.html
Sent from the R help mailing list archive at Nabble.com.
______________________________________________ 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.
Elai
Ok, this is my reproducible example
tm<-structure(list(name_short = structure(1:29, .Label = c("D4",
"D5", "D6a", "D6b", "D6c", "D7", "D8", "F4", "F5a", "F5b", "F6a",
"F6b", "F6c", "F6d", "F7a", "F7b", "F8", "P105", "P114", "P118",
"P123", "P126", "P156", "P157", "P167", "P169", "P189", "P77",
"P81"), class = "factor"), sub_family = structure(c(3L, 3L, 3L,
3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 1L, 1L,
1L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 2L, 2L), .Label = c("pcb mono-ortho subs",
"pcb non-ortho subs", "pcdd", "pcdf"), class = "factor"), tv = c(1.069,
6.461, 5.461, 12.764, 10.86, 117.912, 256.875, 452.204, 124.02,
327.856, 88.469, 61.539, 17.794, 84.117, 121.668, 13.414, 68.409,
3023.333, 428, 19454.667, 151.333, 324, 11478.667, 1220.667,
5335.333, 124.667, 1542.667, 594.667, 193.333), ms = c(1.787,
4.831, 3.456, 14.105, 10.808, 116.02, 296.957, 30.533, 21.821,
32.969, 33.767, 29.799, 12.812, 49.637, 126.522, 17.522, 106.087,
1787.5, 130, 6751.5, 81, 23, 370, 33.5, 147.5, 5.406, 18.5, 415,
69.906)), .Names = c("name_short", "sub_family", "tv", "ms"), class =
"data.frame", row.names = c(NA,
-29L))
and this is my code
#start
library(lattice)
library(latticeExtra)
xyplot(tv ~ ms | sub_family, data=tm,
#as.table=TRUE,
aspect="xy",
xlab = expression(paste('ms [ fg/', m^3, ' ]', sep = '')),
ylab = expression(paste('tv [ fg/', m^3, ' ]', sep = '')),
scales= list(x=list(relation="free", log=10, cex=0.8),
y=list(relation="free", log=10, cex=0.8)),
prepanel = function(x, y, subscripts) {
list(xlim = c(min(x,y), max(x,y)))
list(ylim= c(min(x,y), max(x,y)))
},
panel = function(x, y ,subscripts,...) {
panel.xyplot(x, y, cex=0.8,...)
panel.abline(a = 0, b = 1, lty = 2, col ="gray")
panel.text(x, y, labels=tm$name_short[subscripts], cex = 0.8,
pos=3, offset=0.5, srt=0, adj=c(1,1))
},
subscripts=TRUE,
xscale.components = xscale.components.logpower,
yscale.components = yscale.components.logpower
)
#end
And here in attachment is the graphic output
http://r.789695.n4.nabble.com/file/n4514868/output.png output.png
To answer your question:
- I did not put relation=?same? because that is not what I want: i.e **for
each single panel** (in my case 4) I want to set the same limits for both x
and y axes (I want the diagonal line exactly bisect each panel); see what
happen by putting relation=?same??(I do not want to group the panels by a
single x and y axes)
- I need to set the same number of thick arks for both x and y axes *of each
panel*, but with log scale it?s quite tricky at least seems so to myself)
Thanks for your help
max
--
View this message in context: http://r.789695.n4.nabble.com/xyplot-lattice-fine-control-of-axes-limits-and-thick-marks-with-log-scale-tp4511897p4514868.html
Sent from the R help mailing list archive at Nabble.com.
On Thu, Mar 29, 2012 at 3:04 AM, maxbre <mbressan at arpa.veneto.it> wrote:
<snip>
To answer your question: - I did not put relation=?same? because that is not what I want: i.e **for each single panel** (in my case 4) I want to set the same limits for both x and y axes (I want the diagonal line exactly bisect each panel); see what happen by putting relation=?same??(I do not want to group the panels by a single x and y axes) - I need to set the same number of thick arks for both x and y axes *of each panel*, but with log scale it?s quite tricky at least seems so to myself)
Oh. I missed the *for each panel* aspect of your question. I believe
you are 5 key strokes away (the change is to prepanel). Is this what
you want ?
xyplot(tv ~ ms | sub_family, data=tm,
#as.table=TRUE,
aspect="xy",
xlab = expression(paste('ms [ fg/', m^3, ' ]', sep = '')),
ylab = expression(paste('tv [ fg/', m^3, ' ]', sep = '')),
scales= list(x=list(relation="free", log=10, cex=0.8),
y=list(relation="free", log=10, cex=0.8)),
prepanel = function(x, y, subscripts) {
rr<- range(cbind(x,y))
list(xlim = rr, ylim= rr)
},
panel = function(x, y ,subscripts,...) {
panel.xyplot(x, y, cex=0.8,...)
panel.abline(a = 0, b = 1, lty = 2, col ="gray")
panel.text(x, y, labels=tm$name_short[subscripts], cex = 0.8,
pos=3, offset=0.5, srt=0, adj=c(1,1))
}, subscripts=TRUE,
xscale.components = xscale.components.logpower,
yscale.components = yscale.components.logpower
)
Cheers
Thanks for your help max -- View this message in context: http://r.789695.n4.nabble.com/xyplot-lattice-fine-control-of-axes-limits-and-thick-marks-with-log-scale-tp4511897p4514868.html Sent from the R help mailing list archive at Nabble.com.
______________________________________________ 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.
yes elai, that's what I want! thank you for support maxbre -- View this message in context: http://r.789695.n4.nabble.com/xyplot-lattice-fine-control-of-axes-limits-and-thick-marks-with-log-scale-tp4511897p4518205.html Sent from the R help mailing list archive at Nabble.com.