[R] simple graphing question
I have what should be a simple question but I've been unable to solve it in a reasonable length of time. For example with data like ge product response scenario 1wine5 base 2 steel 10 base 3 sugar4 base 4wine -10 policy 5 steel1 policy 6 sugar -20 policy (In reality there would be similar groups of data of various sizes). I would like to make dotplots with product on the left axis, x's for policy and o's for base scenario, say in red and blue. I would like to have horizontal lines from the product names across thru the x's and o's to the other side. Because positive or negative responses are important, I would like to have a vertical red line top to bottom at 0. I've experimented with dot.line, add.line to put in horizontal lines but was unsuccessful. Although the following code puts a red vertical line in, it is at the plot's left border. gedot - function() { trellis.par.set(list(fontsize=list(text=12), dot.symbol=list(pch=c(1,4), col=c(blue,red)) )) print(dotplot(product ~ response, groups = scenario, pch=c(1,4), xlab=, ylab=NULL)) panel.abline(v=0, col=red, reference=FALSE) } Help please. __ 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.
Re: [R] simple graphing question
If I understand your example correctly, I think you're looking for a dot-chart like this one from the R Graph Gallery: http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=150 You'd just need to replace the green/blue circles with X's and O's, respectively. Provided you reorganize your data the standard dotchart function should do what you need. See the code for the chart in the graph gallery (or here: http://tinyurl.com/dby3jd ). # David Smith -- David M Smith da...@revolution-computing.com Director of Community, REvolution Computing www.revolution-computing.com Tel: +1 (206) 577-4778 x3203 (Seattle, USA) On Mon, Feb 23, 2009 at 12:38 PM, William Deese williamde...@gmail.com wrote: I have what should be a simple question but I've been unable to solve it in a reasonable length of time. For example with data like ge product response scenario 1wine5 base 2 steel 10 base 3 sugar4 base 4wine -10 policy 5 steel1 policy 6 sugar -20 policy (In reality there would be similar groups of data of various sizes). I would like to make dotplots with product on the left axis, x's for policy and o's for base scenario, say in red and blue. I would like to have horizontal lines from the product names across thru the x's and o's to the other side. Because positive or negative responses are important, I would like to have a vertical red line top to bottom at 0. I've experimented with dot.line, add.line to put in horizontal lines but was unsuccessful. Although the following code puts a red vertical line in, it is at the plot's left border. gedot - function() { trellis.par.set(list(fontsize=list(text=12), dot.symbol=list(pch=c(1,4), col=c(blue,red)) )) print(dotplot(product ~ response, groups = scenario, pch=c(1,4), xlab=, ylab=NULL)) panel.abline(v=0, col=red, reference=FALSE) } Help please. __ 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.
[R] simple graphing question
#copy and paste this into R f - (structure(list(TKN = c(0.103011025, 0.018633208, 0.104235702, 0.074537363, 0.138286096), RM = c(215, 198, 148, 119, 61)), .Names = c(TKN, RM), class = data.frame, row.names = 25:29)) plot(f$TKN~f$RM, type=b) I would like to reverse the X-Axis. How do I do this? -- 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 __ 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.
Re: [R] simple graphing question
Try: plot(f$RM~f$TKN, type=b) On Tue, Apr 8, 2008 at 4:18 PM, stephen sefick [EMAIL PROTECTED] wrote: #copy and paste this into R f - (structure(list(TKN = c(0.103011025, 0.018633208, 0.104235702, 0.074537363, 0.138286096), RM = c(215, 198, 148, 119, 61)), .Names = c(TKN, RM), class = data.frame, row.names = 25:29)) plot(f$TKN~f$RM, type=b) I would like to reverse the X-Axis. How do I do this? -- 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 __ 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. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O [[alternative HTML version deleted]] __ 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.
Re: [R] simple graphing question
On Tue, Apr 8, 2008 at 3:52 PM, stephen sefick [EMAIL PROTECTED] wrote: Sorry, to have the x-axis to go from 200 to 0 or to reverse the x points- the line starts on the left hand side of the graph at x=215, y=0.10301103 ... and end with x=61, y=0.13828610. does this make sense? reverse order x-axis in excel is what I would use if this helps On Tue, Apr 8, 2008 at 3:43 PM, Henrique Dallazuanna [EMAIL PROTECTED] wrote: Try: plot(f$RM~f$TKN, type=b) On Tue, Apr 8, 2008 at 4:18 PM, stephen sefick [EMAIL PROTECTED] wrote: #copy and paste this into R f - (structure(list(TKN = c(0.103011025, 0.018633208, 0.104235702, 0.074537363, 0.138286096), RM = c(215, 198, 148, 119, 61)), .Names = c(TKN, RM), class = data.frame, row.names = 25:29)) plot(f$TKN~f$RM, type=b) I would like to reverse the X-Axis. How do I do this? -- 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 __ 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. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O -- 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 -- 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 __ 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.
Re: [R] simple graphing question
This is maybe not the most elegant way, but it does de job. You first put f$RM values in negative form. Then you plot your graph without the x axis labels. After, you create the labels you want. Try this : f - (structure(list(TKN = c(0.103011025, 0.018633208, 0.104235702, 0.074537363, 0.138286096), RM = c(215, 198, 148, 119, 61)), .Names = c(TKN, RM), class = data.frame, row.names = 25:29)) f$rms=f$RM*(-1) plot(f$TKN~f$rms ,xaxt=n, type=b) axis(side=1, seq(min(pretty(f$rms,n=3)),max(pretty(f$rms,n=3)),50), labels=seq(min(pretty(f$rm,n=3))*(-1),max(pretty(f$rm,n=3))*(-1),-50)) Benoit Bruneau Canada On Apr 8, 2008, at 3:52 PM, stephen sefick wrote: On Tue, Apr 8, 2008 at 3:52 PM, stephen sefick [EMAIL PROTECTED] wrote: Sorry, to have the x-axis to go from 200 to 0 or to reverse the x points- the line starts on the left hand side of the graph at x=215, y=0.10301103 ... and end with x=61, y=0.13828610. does this make sense? reverse order x-axis in excel is what I would use if this helps On Tue, Apr 8, 2008 at 3:43 PM, Henrique Dallazuanna [EMAIL PROTECTED] wrote: Try: plot(f$RM~f$TKN, type=b) On Tue, Apr 8, 2008 at 4:18 PM, stephen sefick [EMAIL PROTECTED] wrote: #copy and paste this into R f - (structure(list(TKN = c(0.103011025, 0.018633208, 0.104235702, 0.074537363, 0.138286096), RM = c(215, 198, 148, 119, 61)), .Names = c(TKN, RM), class = data.frame, row.names = 25:29)) plot(f$TKN~f$RM, type=b) I would like to reverse the X-Axis. How do I do this? -- 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 __ 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. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O -- 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 -- 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 __ 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. [[alternative HTML version deleted]] __ 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.
Re: [R] simple graphing question
On Tue, Apr 8, 2008 at 2:18 PM, stephen sefick [EMAIL PROTECTED] wrote: #copy and paste this into R f - (structure(list(TKN = c(0.103011025, 0.018633208, 0.104235702, 0.074537363, 0.138286096), RM = c(215, 198, 148, 119, 61)), .Names = c(TKN, RM), class = data.frame, row.names = 25:29)) plot(f$TKN~f$RM, type=b) I would like to reverse the X-Axis. How do I do this? Hello, Stephen: It appears you might be new in R, so let me point out a couple of things. First, this works: f - data.frame( TKN = c(0.103011025, 0.018633208, 0.104235702,0.074537363, 0.138286096), RM = c(215, 198, 148, 119, 61), row.names = 25:29) plot(TKN~RM, data=f, type=b, xlim=rev(range(f$RM))) Note that I've created your data frame in a more usual way and I've reversed the x axis in the plot by reversing the range of the X variable. I've also used the data option to plot Second, I had reversed an axis before, but I quickly learned how by typing the following command: RSiteSearch(reverse axis) That opened up the web browser and it listed many items, the second of which was this: http://finzi.psych.upenn.edu/R/Rhelp02a/archive/66958.html thread, the title of which is How to reverse the sequence of axis Y ? Generally, if you try RSiteSearch() and don't find what you need after exploring a page or two of threads, then you can post here and ask questions without people saying go read the posting guide before posting questions. Good luck PJ -- Paul E. Johnson Professor, Political Science 1541 Lilac Lane, Room 504 University of Kansas __ 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.