If this is a quick and dirty process you want rather than learning all the 
capabilities that are in R then I would copy the density curve (or the bits you 
like) into your favourite image editor, and use it's capabilities to pretty it 
up.

However there are a number of options. Firstly you have chosen to plot 
density(y). When I looked at the help for density it gives the values returned 
by density. If you want a custom plot maybe you should try

dcurve <- density(y)

you could then directly access the $x and $y components as you would in any plot

For instance plot(density(y)) gives you the grey line. However 
plot(dcurve$x,dcurve$y,type = "l") gives you a different type of plot.

As for arrowheads one could create an appropriate "polygon" to stick at each 
end. Which for a one off might be a bit of overkill. Sometime in all of this 
you'll also probably encounter clipping, in which case par(xpd = TRUE) will 
often help. Just remember to turn if off or you may find unwanted graphics 
appearing later on.

For putting the labels where you want you could use "mtext." This gives you 
control over where you want to place the text.

A word of caution. If you are going to start prettying up you plots to very 
specific standards make sure that you are working on the final device from 
which you wish to take the final copy. Each of the devices have their own 
capabilities which are often not related to R but rather to their own 
environment. That is you can't get a plot looking perfect in a window and 
assume that the same code sent to a postscript device will produce identical 
results. 

R can give you very good graphics, often straight out of the box, but like any 
publishing process it can be a bit fiddly.

Tom Mulholland
Senior Demographer
Department for Planning and Infrastructure
Perth, WA, Australia.




-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Wednesday, 17 November 2004 2:39 PM
To: [EMAIL PROTECTED]
Subject: [R] How to plot this


Hi there,

 

I produced a plot using the following codes:

 

y<-rnorm(1000, 2, 0)

x0<-c(0, 0)

y0<-c(0, 0)

y1<-c(0, 1)

x1<-c(0, 4)

plot(density(y), ylab="Abundance of species", xlab="Environmental
gradient", main=" ", 

   xlim=c(0, 4), ylim=c(0, 1), lty=2, col=4, xaxt="n", yaxt="n",
frame.plot=F)

lines(x0, y1) # add an axis

lines(x1, y0) # add an axis

arrows(3.95, 0, 4, 0,  angle = 15, length = 0.1)

arrows(0, 0.98, 0, 1,  angle = 15, length = 0.1)

 

Please help me to remove the grey horizontal line and put the axis
labels closer to the axes. And also appreciate any suggestions on how to
make those arrows look nicer, e.g. a filled small arrow for each axis,
like what from points(0, 1,   pch=17), but a slightly narrowed one.
Thanks.

 

Regards,

 

Jin Li

========================

Jin Li, PhD

Climate Impacts Modeller

CSIRO Sustainable Ecosystems

Atherton, QLD 4883, Australia

========================

 


        [[alternative HTML version deleted]]

______________________________________________
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

______________________________________________
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to