[R] Dot plot with two grouping variables concurrently
markm0705
markm0705 at gmail.com
Sun Aug 21 13:18:50 CEST 2011
Dear R help(ers). I'm an R-learner (about 10 hours now) trying to make a
ranked dot plot where the symbols are coded by two variables concurrently.
I'm trying to use Deepanyan Sarkar's book 'Lattice' as a guide but get the
feeling it is a bit advanced for my level of understanding.
I have three questions
Q1.
Right now I like to know how to get the dual coding working on the points on
a dotplot and also annotate these in a key. Specifically I'm attempting to
code the fill of the points by a variable called 'Commodity' but would like
have different symbols to refelect a second variable called 'Year' (say
square, triangle and circle for different years).
My code so far is as follows:
## initalise
library("lattice")
##read the data to a variable
Cal_dat <- read.table("Calibration2.dat",header = TRUE,sep = "\t",)
## set up plotting colours for the fills
col.pat<-c("violet","cyan","green","red","blue","black","yellow")
##set up the plot key to be inside the plot
plot.key<-list(
corner=c(1,0),
text=list(levels(Cal_dat$Commodity)),
title="Ore type",
points=list(pch=21,cex=1.3,fill=col.pat,col="black")
)
##set some parameters for the dotplot
trellis.par.set(
dot.line=list(col = "transparent"),
axis.line=list(col = "grey90"),
axis.text=list(col ="grey50", cex=0.8),
panel.background=list(col="grey98"),
par.xlab.text= list(col="grey50")
)
## Create the dot plot
dotplot(reorder(Mine, Resc_Gt)~ Resc_Gt,groups=Commodity,
data=Cal_dat,
cex=1.2,
pch=21,
aspect=2.0,
key=plot.key,
col="black",
fill=col.pat,
origin=0,
type = c("p", "h"),
main = "Resource Tonnage",
xlab= "tonnes (billions)"
)
The dot plot so far is attached as well as the input data.
Q2
I'm puzzled by the waring message (below) I get when runnin the current code
as follows (What does this mean and why does it occur).
"Warning message:
In trellis.par.set(dot.line = list(col = "transparent"), axis.line =
list(col = "grey90"), :
Note: The default device has been opened to honour attempt to modify
trellis settings"
Q3
Can anybody recommend a good 'starters' book for learning plotting in R that
is reasonably clear on the basics. My primary interest is the graphing
tools that are in lattice (hence trying the Deepayan Sarkar book), but I'm
finding this guide rather tough going.
Thanks in advance - MarkM
http://r.789695.n4.nabble.com/file/n3758248/Calibration2.dat
Calibration2.dat
http://r.789695.n4.nabble.com/file/n3758248/Ranked_boxplot_by_commodity.png
Ranked_boxplot_by_commodity.png
--
View this message in context: http://r.789695.n4.nabble.com/Dot-plot-with-two-grouping-variables-concurrently-tp3758248p3758248.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list