Skip to content

histogram-like plot with two variables

6 messages · Jörg Groß, jim holtman, Duncan Murdoch +3 more

#
Try:

plot(x,y,type='s')
lines(x,y, type='h')
On Sun, Sep 28, 2008 at 10:02 PM, J?rg Gro? <joerg at licht-malerei.de> wrote:

  
    
#
On 28/09/2008 10:02 PM, J?rg Gro? wrote:
You could use barplot():

barplot(y,names=x)

You could also do it with plot.histogram, but it's trickier, because 
it's designed for continuous data.  For example,

dat <- hist(x, plot=FALSE, breaks=c(-1,x)+0.5)
dat$density <- y
plot(dat, freq=FALSE)

Duncan Murdoch
#
J?rg Gro? wrote:
Hi Jorg,
Does this do what you want?

library(plotrix)
barp(y,names.arg=0:14)


Jim
#
On Mon, Sep 29, 2008 at 04:02:05AM +0200, J?rg Gro? wrote:
yes - the lwd parameter controls line width. E.g.:

plot(x,y, type='h', lwd=5)

This is the way I usually plot count data - I prefer this over something
that looks like a normal histogram, because it reminds me that I am
looking at discrete values.

cu
	Philipp
#
An added note, if you use this approach, then you should probably set the lend parameter as well (becomes more important with wider lines).  See ?par and scroll down to lend for options/details.

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111