I have the code below and it works fine if I print the xyplot but if I
take the print out, then I just get a blank
pdf. The same holds if I just send the plot to the console without the
print ( I get nothing ). My question is whether this is always
the case with xyplot or is there something wrong with my settings ? I am
on linux ( redhat ) and using R.2.5.0. Thanks.
load("stocks.dat")
pdf('temp.pdf', width=10, height=8)
trellis.par.set(superpose.symbol=list(pch=19, cex=0.8)) # filled circles
print(xyplot(value ~ date|group, groups=wt, data=stocks.all, type='o',
layout=c(2,2),
auto.key=list(columns=6), scales=list(x=list(rot=90))))
dev.off()
#=================================================================================================================
sessionInfo()
R version 2.5.0 (2007-04-23)
i686-pc-linux-gnu
locale:
C
attached base packages:
[1] "datasets" "utils" "stats"
"graphics" "grDevices"
"methods" "base"
other attached packages:
lattice filehash reshape zoo chron MASS
"0.15-8" "1.0" "0.7.4" "1.3-1"
"2.3-11" "7.2-33"
--------------------------------------------------------
This is not an offer (or solicitation of an offer) to buy/se...{{dropped}}
-------- Original Message -------- Subject: [R] xyplot question From: Leeds, Mark (IED) <Mark.Leeds at morganstanley.com> To: r-help at stat.math.ethz.ch Date: 11.09.2007 18:00> > load("stocks.dat") > > pdf('temp.pdf', width=10, height=8) >does ist work with postscript? something like: postscript("temp.ps", width = 10.0, height = 8.0, horizontal = FALSE, onefile =T, paper="special") Stefan -=-=- ... Time is an illusion, lunchtime doubly so. (Ford Prefect)
On 9/11/07, Leeds, Mark (IED) <Mark.Leeds at morganstanley.com> wrote:> I have the code below and it works fine if I print the xyplot but if I > take the print out, then I just get a blank > pdf. The same holds if I just send the plot to the console without the > print ( I get nothing ). My question is whether this is always > the case with xyplot or is there something wrong with my settings ? I am > on linux ( redhat ) and using R.2.5.0. Thanks.I don't have your stock.dat, but running the following in a fresh R session does give me a PDF file with the expected plot. $ R-devel --vanilla R version 2.6.0 Under development (unstable) (2007-08-06 r42439) [...]> library(lattice) > pdf('temp.pdf', width=10, height=8) > xyplot(1:10 ~ 1:10) > dev.off()Are you sure you are not doing this inside a function (maybe source)? -Deepayan> > > load("stocks.dat") > > pdf('temp.pdf', width=10, height=8) > > trellis.par.set(superpose.symbol=list(pch=19, cex=0.8)) # filled circles > > print(xyplot(value ~ date|group, groups=wt, data=stocks.all, type='o', > layout=c(2,2), > auto.key=list(columns=6), scales=list(x=list(rot=90)))) > > dev.off() > > #======================================================================> ===========================================> > > sessionInfo() > R version 2.5.0 (2007-04-23) > i686-pc-linux-gnu > > locale: > C > > attached base packages: > [1] "datasets" "utils" "stats" "graphics" "grDevices" > "methods" "base" > > other attached packages: > lattice filehash reshape zoo chron MASS > "0.15-8" "1.0" "0.7.4" "1.3-1" "2.3-11" "7.2-33" > -------------------------------------------------------- > > This is not an offer (or solicitation of an offer) to buy/se...{{dropped}} > > ______________________________________________ > 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. >
I am tring to do an xyplot where I want to plot 5 dots in each pane of
the trellice and the dots need to have lines (whiskers) extending up
and down at each point(plus a 45 degree reference line). The data
frame is set up with the variables x y lcl and ucl (where the lcl and
ucl are the limits on the lines I want). The code below gives me the
points but I cant figure out the lines limited by the lcl and ucl
variable.
library(lattice)
library(grid)
with(fig2,
xyplot(y ~ x | group * Method,
xlab = "",
xlim = c(-5, 1),
ylab = "",
ylim = c(-5, 1),
col = "black",
groups = group,
aspect = 1,
panel = function(x, y, ...) {
panel.superpose(x, y, ...)
panel.abline(0, 1)
},
)
)
The not trellice version of the first image I need in the xyplot can
be done like this:
with(sub1,
plot(y~x,
xlim = c(-5,1),
ylim = c(-5,1)
)
)
abline (0, 1)
lines(rep(sub1$x[1],2), c(sub1$lcl[1], sub1$ucl[5]))
lines(rep(sub1$x[2],2), c(sub1$lcl[2], sub1$ucl[5]))
lines(rep(sub1$x[3],2), c(sub1$lcl[3], sub1$ucl[5]))
lines(rep(sub1$x[4],2), c(sub1$lcl[4], sub1$ucl[5]))
lines(rep(sub1$x[5],2), c(sub1$lcl[5], sub1$ucl[5]))
How can i tell it to use the lcl and ucl values to draw the whiskers I
need above and below the points?
On 9/14/07, Raymond Balise <iteachtyping at gmail.com> wrote:> I am tring to do an xyplot where I want to plot 5 dots in each pane of > the trellice and the dots need to have lines (whiskers) extending up > and down at each point(plus a 45 degree reference line). The data > frame is set up with the variables x y lcl and ucl (where the lcl and > ucl are the limits on the lines I want). The code below gives me the > points but I cant figure out the lines limited by the lcl and ucl > variable.demo("intervals", package = "lattice") should get you most of the way. The source should be easier to read from https://svn.r-project.org/R-packages/trunk/lattice/demo/intervals.R You can ignore most of it; you just need prepanel.ci, panel.ci, and the xyplot() call at the end. -Deepayan
I am tring to add error bars to data in an xyplot. Below is the
content of a CSV file that I am trying to use and the code which plots
the data points and 45 degree lines in each of the panes of the
trellice. I want to add error bars that go up and down to the limits
set by the lcl and ucl values in the data set. How the heck can I
specify the error bars in a lattice plot?
If anyone knows how to do this can you please tell me how to do it and
more importantly point me toward a book/paper that explains how to do
this and has examples. :~) As always, help is profoundly appreciated.
fig2 = read.xls("figure2.csv")
library(lattice)
library(grid)
with(fig2,
xyplot(y ~ x | group * Method,
xlab = "",
xlim = c(-5, 1),
ylab = "",
ylim = c(-5, 1),
col = "black",
groups = group,
aspect = 1,
lx = lcl,
ux = ucl,
pch = 16 ,
panel = function(x, y, ...) {
panel.superpose(x, y, ...)
panel.abline(0, 1)
},
)
)
###### some sample data for a CSV file ############
Method,group,x,y,lcl,ucl
A,Black,-3.018626791,-1.461326791,-2.068936791,-0.867106791
A,Black,-3.304632403,-2.608322403,-3.463632403,-1.768972403
A,Black,-2.673500283,-2.100820283,-2.708560283,-1.507230283
A,Black,-1.700734807,-0.887104807,-1.275424807,-0.524394807
A,Black,-0.586121342,-0.848638342,-1.169118342,-0.551044342
A,Yellow,-3.136580929,-1.120380929,-1.720710929,-0.550799929
A,Yellow,-2.757574147,-1.021674147,-1.474644147,-0.600298147
A,Yellow,-2.17890461,-0.89563461,-1.34797461,-0.47309861
A,Yellow,-1.812551095,-0.920201095,-1.215711095,-0.639398095
A,Yellow,-1.054284002,-1.195239002,-1.453922002,-0.956836002
A,Green,-1.639312507,-4.174222507,-4.174222507,-4.174222507
A,Green,-1.23917727,-0.30492427,-0.68852327,-0.21611447
A,Green,-0.66966805,-1.13230605,-1.99186605,-0.49901105
A,Green,0.278895635,0.096514635,-0.301298365,0.300602935
A,Green,-0.504911532,-0.894806332,-1.378339332,-0.603663332
A,Blue,-2.969196277,-3.693096277,-3.820696277,-1.384526277
A,Blue,-2.419573959,-2.280913959,-2.894093959,-1.672893959
A,Blue,-1.773659064,-1.850719064,-2.450169064,-1.260569064
A,Blue,-1.510092543,-0.851495543,-1.439472543,-0.411152543
A,Blue,-0.595168746,-0.998596746,-1.208087746,-0.805696746
B,Black,-2.459224263,-1.757114263,-2.364714263,-1.162324263
B,Black,-1.817291831,-1.704651831,-2.557361831,-0.868041831
B,Black,-2.495591512,-2.614881512,-3.456411512,-1.789931512
B,Black,-1.216945891,-0.928095891,-1.315455891,-0.557498891
B,Black,-0.500977651,-0.518668651,-0.817970651,-0.249855651
B,Yellow,-2.473182951,-1.310892951,-1.909672951,-0.741403951
B,Yellow,-2.085555297,-0.856005297,-1.252555297,-0.489987297
B,Yellow,-2.249602851,-1.539112851,-2.010652851,-1.093110851
B,Yellow,-1.406241001,-0.872741001,-1.183891001,-0.577481001
B,Yellow,-0.953045757,-0.981668757,-1.241857757,-0.740871757
B,Green,-2.487720209,-4.310240209,-4.310240209,-4.310240209
B,Green,-2.472235352,-0.579902352,-0.963501352,-0.491092552
B,Green,-1.35388464,-0.39377464,-0.99212464,0.00267836
B,Green,-1.20222519,-0.58276419,-1.05847819,-0.30239519
B,Green,-0.155542679,-0.302979679,-0.795866679,-0.000590679
B,Blue,-2.467137219,-2.879317219,-3.541517219,-2.219037219
B,Blue,-2.093208678,-2.467378678,-3.037568678,-1.901558678
B,Blue,-1.968546702,-1.171728702,-1.881726702,-0.642598702
B,Blue,-1.067931387,-1.109401387,-1.445171387,-0.785811387
B,Blue,-0.936799562,-1.166112562,-1.361216562,-0.987562562
The following link is an excellent reference which gives R code for making
different plots in R.
http://addictedtor.free.fr/graphiques/thumbs.php
Is it something like this you want:
http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=52
The code can be found to do this on the webpage.
Regards
Wayne
-----Original Message-----
From: r-help-bounces at r-project.org
[mailto:r-help-bounces at r-project.org]On Behalf Of Raymond Balise
Sent: 18 September 2007 23:52
To: r-help at stat.math.ethz.ch
Subject: [R] xyplot question
I am tring to add error bars to data in an xyplot. Below is the
content of a CSV file that I am trying to use and the code which plots
the data points and 45 degree lines in each of the panes of the
trellice. I want to add error bars that go up and down to the limits
set by the lcl and ucl values in the data set. How the heck can I
specify the error bars in a lattice plot?
If anyone knows how to do this can you please tell me how to do it and
more importantly point me toward a book/paper that explains how to do
this and has examples. :~) As always, help is profoundly appreciated.
fig2 = read.xls("figure2.csv")
library(lattice)
library(grid)
with(fig2,
xyplot(y ~ x | group * Method,
xlab = "",
xlim = c(-5, 1),
ylab = "",
ylim = c(-5, 1),
col = "black",
groups = group,
aspect = 1,
lx = lcl,
ux = ucl,
pch = 16 ,
panel = function(x, y, ...) {
panel.superpose(x, y, ...)
panel.abline(0, 1)
},
)
)
###### some sample data for a CSV file ############
Method,group,x,y,lcl,ucl
A,Black,-3.018626791,-1.461326791,-2.068936791,-0.867106791
A,Black,-3.304632403,-2.608322403,-3.463632403,-1.768972403
A,Black,-2.673500283,-2.100820283,-2.708560283,-1.507230283
A,Black,-1.700734807,-0.887104807,-1.275424807,-0.524394807
A,Black,-0.586121342,-0.848638342,-1.169118342,-0.551044342
A,Yellow,-3.136580929,-1.120380929,-1.720710929,-0.550799929
A,Yellow,-2.757574147,-1.021674147,-1.474644147,-0.600298147
A,Yellow,-2.17890461,-0.89563461,-1.34797461,-0.47309861
A,Yellow,-1.812551095,-0.920201095,-1.215711095,-0.639398095
A,Yellow,-1.054284002,-1.195239002,-1.453922002,-0.956836002
A,Green,-1.639312507,-4.174222507,-4.174222507,-4.174222507
A,Green,-1.23917727,-0.30492427,-0.68852327,-0.21611447
A,Green,-0.66966805,-1.13230605,-1.99186605,-0.49901105
A,Green,0.278895635,0.096514635,-0.301298365,0.300602935
A,Green,-0.504911532,-0.894806332,-1.378339332,-0.603663332
A,Blue,-2.969196277,-3.693096277,-3.820696277,-1.384526277
A,Blue,-2.419573959,-2.280913959,-2.894093959,-1.672893959
A,Blue,-1.773659064,-1.850719064,-2.450169064,-1.260569064
A,Blue,-1.510092543,-0.851495543,-1.439472543,-0.411152543
A,Blue,-0.595168746,-0.998596746,-1.208087746,-0.805696746
B,Black,-2.459224263,-1.757114263,-2.364714263,-1.162324263
B,Black,-1.817291831,-1.704651831,-2.557361831,-0.868041831
B,Black,-2.495591512,-2.614881512,-3.456411512,-1.789931512
B,Black,-1.216945891,-0.928095891,-1.315455891,-0.557498891
B,Black,-0.500977651,-0.518668651,-0.817970651,-0.249855651
B,Yellow,-2.473182951,-1.310892951,-1.909672951,-0.741403951
B,Yellow,-2.085555297,-0.856005297,-1.252555297,-0.489987297
B,Yellow,-2.249602851,-1.539112851,-2.010652851,-1.093110851
B,Yellow,-1.406241001,-0.872741001,-1.183891001,-0.577481001
B,Yellow,-0.953045757,-0.981668757,-1.241857757,-0.740871757
B,Green,-2.487720209,-4.310240209,-4.310240209,-4.310240209
B,Green,-2.472235352,-0.579902352,-0.963501352,-0.491092552
B,Green,-1.35388464,-0.39377464,-0.99212464,0.00267836
B,Green,-1.20222519,-0.58276419,-1.05847819,-0.30239519
B,Green,-0.155542679,-0.302979679,-0.795866679,-0.000590679
B,Blue,-2.467137219,-2.879317219,-3.541517219,-2.219037219
B,Blue,-2.093208678,-2.467378678,-3.037568678,-1.901558678
B,Blue,-1.968546702,-1.171728702,-1.881726702,-0.642598702
B,Blue,-1.067931387,-1.109401387,-1.445171387,-0.785811387
B,Blue,-0.936799562,-1.166112562,-1.361216562,-0.987562562
______________________________________________
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.