

Hi Rusers
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 xaxis is not positioned equal for the two plotting functions (see picture) and I have been unable to find out how this is changed.
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


Is there anyway you could include the data so we can see what the problem
is I am getting better at this code reading stuff, but it reduces my time
if I can just copy it into my R session and then fiddle.
thanks
Stephen
On Fri, Jun 20, 2008 at 4:39 AM, Thomas Pedersen < [hidden email]> wrote:
>
> Hi Rusers
>
> 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 xaxis 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
> 
> View this message in context:
> http://www.nabble.com/Plottingbarplotandscatterplotonsamedevicexaxisproblemtp18025066p18025066.html> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/rhelp> PLEASE do read the posting guide
> http://www.Rproject.org/postingguide.html> and provide commented, minimal, selfcontained, reproducible code.
>

Let's not spend our time and resources thinking about things that are so
little or so large that all they really do for us is puff us up and make us
feel like gods. We are mammals, and have not exhausted the annoying little
problems of being mammals.
K. Mullis
[[alternative HTML version deleted]]
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Of course :)  here you go...
Data.txtThe data is tabseparated
Thanks for the reply


On Fri, 20080620 at 01:39 0700, Thomas Pedersen wrote:
> Hi Rusers
>
> 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 xaxis is not positioned equal for the
> two plotting functions (see picture) and I have been unable to find out how
> this is changed.
Hi Thomas,
You might find that "barp" in the plotrix package will do what you want
as it centers the bars on integral values.
Jim
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


As an alternative to the other suggestions,
I've found it just as easy to make the bar plot using plot() .
Assuming I've run hist()>sudh, then do
plot(sudh$breaks[1:length(sudh$breaks)1],sudh$counts,type='h',lwd={pick_a_width_you_like))
Then it's easy to drop some scatterplot points or lines on top of that.
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


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 Rusers
>
> 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 xaxis 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
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.

