Is this what you want: y1 <- c(-30353.382, -21693.519, -7049.923, -72968.722, -10267.584, -269432.795, -19847.670, -686283.171, -376231.754, -597800.080, -274637.587, -112663.167, -39550.445, -133916.431)
xlabs <- c(1, 7, 13, 2, 8, 14, 3, 9, 4, 10, 5, 11, 6, 12) y2 <- c(50, 25, 5, 25, 5, 100, 5, 100, 100, 75, 75, 50, 50, 50) par(mar=c(5,4,4,4)+0.1, xpd=NA) tmp <- barplot(y1, names=xlabs) library(TeachingDemos) updateusr(1:2, range(0,y1), 1:2, range(y2) ) points( tmp, y2 ) axis(4) # or possibly points( tmp, y2[ order(order(xlabs)) ], col='green' ) -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 > -----Original Message----- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- > project.org] On Behalf Of dan.weavesham > Sent: Thursday, June 24, 2010 1:47 PM > To: r-help@r-project.org > Subject: Re: [R] Correctly plotting bar and scatter chart on 2-y axis > plot with par(new=T) > > > Hello, > > Thanks for the advice so far -- still struggling with it, I must admit. > > Here is some sample data, which I hope helps: > > # y axis #1 -- data for the bar chart > -30353.382 -21693.519 -7049.923 -72968.722 -10267.584 -269432.795 > -19847.670 -686283.171 -376231.754 -597800.080 -274637.587 -112663.167 > -39550.445 -133916.431 > > # x axis -- in specific order, so cannot be tampered with !! ;-) > 1 7 13 2 8 14 3 9 4 10 5 11 6 12 > > # y axis #2 -- scatter chart > 50 25 5 25 5 100 5 100 100 75 75 50 50 50 > > Does this help explain what I'm looking to do? If not, is there a way I > can > get plot() to not change the order of the x axis data points -- so > instead > of plotting 1,2,3,n as per my original post, it plots 1,7,13,n? (I've > tried > coercing the data into character format with no luck) > > Thanks again in advance. > > -- > View this message in context: http://r.789695.n4.nabble.com/Correctly- > plotting-bar-and-scatter-chart-on-2-y-axis-plot-with-par-new-T- > tp2266589p2267550.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@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. ______________________________________________ R-help@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.