[R] New user help with plot.default
John Kane
jrkrideau at yahoo.ca
Thu Aug 2 14:53:41 CEST 2007
Hi Paul,
I think one of the problems is that xlim is expecting
a numerical vector something like c(1:8) implying a
contiuous variable and yours is categorical.
I have made quite few changes but does this do what
you want? It may not be the most effient but it runs
:)
-----------------------------------------------------
#set axis label and tick mark label font sizes to be
readable when pasted into final document
mydata <-
read.table("http://www.nabble.com/file/p11963282/TELrange.csv",
sep=",", header=TRUE)
OrderedLevels<-factor(mydata$Chemical,levels=c("Cd",
"Cu", "Zn", "Phen", "Ant",
"Flu", "Pyr", "Tot"))
chems <-
c("Cd","Cu","Zn","Phe","Ant","Flu","Pyr","Tot")
par(cex.lab=1.2,cex.axis=1.3)
#produce plot with plotting symbols of round black
dots with cex multiplier of 1.5
# remove the default axes in the plot (axes=FALSE)
plot.default(mydata$SQG~OrderedLevels,cex=1.5,pch=16,col=1,
axes=FALSE,
xlab = "Chemical",ylab = expression(paste("
",Log[10]," metal ("*m*g*~kg^{-1},")
or PAH ("*mu*g*~kg^{-1},") SQG")))
# Draw the specific axes.
axis(1, at=1:8, labels=chems)
axis(2, at=0:3, labels=c("1","2","3")
-------------------------------------------------------
--- PaulGaskell <p.gaskell at sheffield.ac.uk> wrote:
>
> Hi - I'm just starting out with R and have come up
> against a problem with
> what should be a simple operation. I'm plotting a
> range of safety standards
> for 7 different chemicals. I don't want the standard
> box and whisker plot -
> I just a dot for each value. Whilst using
> "plot.default" I get the error
> "invalid xlim value" - which is confusing since
> using the same script with
> "plot" does not produce this error. However, I do
> notice that only alternate
> xlim tick mark labels appear when using "plot".
> Therefore, a question in 2
> parts - firstly what is incompatible about my xlim
> argument with
> plot.default and secondly, how do I suppress the
> "check.overlap" for tick
> mark labels in plot.default?
>
> Annotated script below (data file also uploaded in
> case its useful) and
> thanks in advance for any help:
>
> #dataframe is column of numerical values of chemical
> safety guidelines "SQG"
> plus a column identifying the chemicals to which
> each value pertains i.e.
> # SQG Chemical
> #1 0.07918 Cd
> #2 -0.15490 Cd
> #3 -0.15490 Cd
> #4 0.95904 Cd
> #5....etc. etc.
> #assign correct plotting order for each chemical
> level
> OrderedLevels<-factor(Chemical,levels=c("Cd", "Cu",
> "Zn", "Phen", "Ant",
> "Flu", "Pyr", "Tot"))
> #set axis label and tick mark label font sizes to be
> readable when pasted
> into final document
> par(cex.lab=1.2,cex.axis=1.3)
> #produce plot with plotting symbols of round black
> dots with cex multiplier
> of 1.5
>
plot.default(SQG~OrderedLevels,cex=1.5,pch=16,col=1,xlim=c("Cd","Cu","Zn","Phe","Ant","Flu","Pyr","Tot"),xlab
> = "Chemical",ylab = expression(paste(" ",Log[10],"
> metal ("*m*g*~kg^{-1},")
> or PAH ("*mu*g*~kg^{-1},") SQG")))
>
> http://www.nabble.com/file/p11963282/TELrange.csv
> TELrange.csv
> --
> View this message in context:
>
http://www.nabble.com/New-user-help-with-plot.default-tf4205767.html#a11963282
> Sent from the R help mailing list archive at
> Nabble.com.
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
>
More information about the R-help
mailing list