Re: [R] Plotting barplot and scatterplot on same device - x-axis problem

From: Francisco J. Zagmutt <gerifalte28_at_hotmail.com>
Date: Fri, 20 Jun 2008 15:12:38 -0600

You could try using the arguments type, lwd and lend in the call to plot(). For example:

plot(1:10, type="h", lend=2, lwd=10)
points((1:10)*1.1, type="b")

type="h" creates vertical lines under each observation, lwd controls the thickness of the lines, and lend=2 draws square ends on the lines.

I hope this helps,

Francisco

Thomas Pedersen wrote:
> Hi R-users
>
> I'm a relative newbie and uses R mostly for graphical purpose. I have a
> layout problem when plotting a scatterplot and a barplot using
> par(new=TRUE). The baseline of the x-axis is not positioned equal for the
> two plotting functions (see picture) and I have been unable to find out how
> this is changed.
>
> http://www.nabble.com/file/p18025066/pic.jpeg
>
> I have added the script if this is of interrest:
>
> par(mar = c(7, 4, 4, 2) + 0.1)
>
> barplot(rbind(data$Asn,data$Glu,data$NH3),
> beside=T,
> axes=TRUE,
> xlim=c(0,57),
> ylim=c(0,10))
>
> par(new=TRUE)
>
> plot(1:14,data$Acidification.time,
> axes=FALSE,
> type="b",
> xlab="",
> ylab="",
> xlim=c(0.3,14.7),
> ylim=c(6,8))
>
> axis(1,pos=6,
> labels=FALSE,
> at=c(0.3,1:14,14.7))
>
> text(1:14, par("usr")[3], srt = 90, adj = 1,
> labels = data$Month, xpd = TRUE)
>
> axis(4,pos=14.7)
>
> All help will be greatly appreciated



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. Received on Fri 20 Jun 2008 - 21:33:25 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 20 Jun 2008 - 23:31:15 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive