Unit of legend() coordinates (was: Re: [R] lines and legend)
Dear all, I would like to make a suggestion for an improvement (IMHO) of ?legend. Please add a remark that the x,y positioning coordinates are in the units of the plot() itself, *not* in pixels or anything the like. It would have saved me a lot of time figuring out why my legend just wouldn't appear if ?legend would have told me to set the coordinates in the units of the x and y axis. I haven't found it anywhere on the list or manuals (but I may have missed something). Now that I know this, it seems a logic choice, however, refering to a 'graphics device' seems to imply a coordinate system in pixels starting from the upper/lower left of the device (the usual choice in graphical manipulations in programming languages). This assumption is false and IMHO is nowhere in FAQ/manuals contradicted. regards, Paul --On dinsdag 1 juli 2003 11:23 -0700 Anna H. Pryor [EMAIL PROTECTED] wrote: Yes, I am using plot and then lines. The legend is just not appearing. I am using the coordinates of the legend (150,4) which work on boxplot and plot. I have not looked at the output of par (I don't know how to) to see if they are in the region. I assumed if they worked for plot and boxplot they would also for lines. On Tuesday 01 July 2003 11:16, you wrote: I assume that you are calling 'plot' and then 'lines'. Is the legend just not appearing? what are you using for the coordinates of the legend? Have you looked at the output from par to see if these values are within the plot region? When I am trying to put a legend on a plot where I am using lines, R just ignores it. I can do it with boxplot or plot, but just not with lines. Am I doing something wrong? Maybe I am just making a mistake? -- Paul Lemmens NICI, University of Nijmegen ASCII Ribbon Campaign /\ Montessorilaan 3 (B.01.03)Against HTML Mail \ / NL-6525 HR Nijmegen X The Netherlands / \ Phonenumber+31-24-3612648 Fax+31-24-3616066 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: Unit of legend() coordinates (was: Re: [R] lines and legend)
On Wed, 2 Jul 2003, Paul Lemmens wrote: I would like to make a suggestion for an improvement (IMHO) of ?legend. Please add a remark that the x,y positioning coordinates are in the units of the plot() itself, *not* in pixels or anything the like. That's true of all x-y coordinates of all R plotting functions. We don't say it in ?points, for example. It would have saved me a lot of time figuring out why my legend just wouldn't appear if ?legend would have told me to set the coordinates in the units of the x and y axis. I haven't found it anywhere on the list or manuals (but I may have missed something). Now that I know this, it seems a logic choice, however, refering to a 'graphics device' seems to imply a coordinate system in pixels starting from the upper/lower left of the device (the usual choice in graphical manipulations in programming languages). This assumption is false and IMHO is nowhere in FAQ/manuals contradicted. There are several examples on the help page for legend which contradict that assumption, so I don't see how you can have maintained it after reading them, let alone after trying them out. The coordinate systems are explained in detail in `An Introduction to R': The phrase `graphics device' does not appear on the help page for legend, so you must have found that somewhere else. Is it reasonable to expect the help system/manuals to contradict all possible misconceptions of all users? If we attempted to do that, the help pages would get impossibly cluttered by even those misconceptions which come to light. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] lines and legend
When I am trying to put a legend on a plot where I am using lines, R just ignores it. I can do it with boxplot or plot, but just not with lines. Am I doing something wrong? Maybe I am just making a mistake? Anna __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] lines and legend
Yes, I am using plot and then lines. The legend is just not appearing. I am using the coordinates of the legend (150,4) which work on boxplot and plot. I have not looked at the output of par (I don't know how to) to see if they are in the region. I assumed if they worked for plot and boxplot they would also for lines. Anna On Tuesday 01 July 2003 11:16, you wrote: I assume that you are calling 'plot' and then 'lines'. Is the legend just not appearing? what are you using for the coordinates of the legend? Have you looked at the output from par to see if these values are within the plot region? __ James Holtman What is the problem you are trying to solve? Executive Consultant -- Office of Technology, Convergys [EMAIL PROTECTED] (513) 723-2929 Anna H. Pryor [EMAIL PROTECTED]To: R-help mailing list [EMAIL PROTECTED] a.gov cc: Sent by: Subject: [R] lines and legend [EMAIL PROTECTED] ath.ethz.ch 07/01/2003 13:45 When I am trying to put a legend on a plot where I am using lines, R just ignores it. I can do it with boxplot or plot, but just not with lines. Am I doing something wrong? Maybe I am just making a mistake? Anna __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] lines and legend
Hi Anna, What I often do before calling legend is reset the user-coordinates to the unit square. As in: plot(x = 1:100, y = 1:100, col = red) par(usr = c(0, 1, 0, 1)) # now place legend in upper left hand corner legend(x = 0.02, y = 0.98, legend = test, col = red, pch = 1) Hope this is helpful, Sundar Anna H. Pryor wrote: Yes, I am using plot and then lines. The legend is just not appearing. I am using the coordinates of the legend (150,4) which work on boxplot and plot. I have not looked at the output of par (I don't know how to) to see if they are in the region. I assumed if they worked for plot and boxplot they would also for lines. Anna On Tuesday 01 July 2003 11:16, you wrote: I assume that you are calling 'plot' and then 'lines'. Is the legend just not appearing? what are you using for the coordinates of the legend? Have you looked at the output from par to see if these values are within the plot region? __ James Holtman What is the problem you are trying to solve? Executive Consultant -- Office of Technology, Convergys [EMAIL PROTECTED] (513) 723-2929 Anna H. Pryor [EMAIL PROTECTED]To: R-help mailing list [EMAIL PROTECTED] a.gov cc: Sent by: Subject: [R] lines and legend [EMAIL PROTECTED] ath.ethz.ch 07/01/2003 13:45 When I am trying to put a legend on a plot where I am using lines, R just ignores it. I can do it with boxplot or plot, but just not with lines. Am I doing something wrong? Maybe I am just making a mistake? Anna __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] lines and legend
Hi, Have you specified the lty and/or col in legend? For example, are the following codes work? plot(1:10, type = n) lines(c(1, 10), c(1, 10)) lines(c(1, 9), c(0, 10), col = red) legend(8, 2, col = c(black, red), lty = 1, legend = c(FOO, FRED)) On Tue, 1 Jul 2003, Anna H. Pryor wrote: Date: Tue, 1 Jul 2003 11:23:55 -0700 From: Anna H. Pryor [EMAIL PROTECTED] To: R-help mailing list [EMAIL PROTECTED] Subject: Re: [R] lines and legend Yes, I am using plot and then lines. The legend is just not appearing. I am using the coordinates of the legend (150,4) which work on boxplot and plot. I have not looked at the output of par (I don't know how to) to see if they are in the region. I assumed if they worked for plot and boxplot they would also for lines. Anna On Tuesday 01 July 2003 11:16, you wrote: I assume that you are calling 'plot' and then 'lines'. Is the legend just not appearing? what are you using for the coordinates of the legend? Have you looked at the output from par to see if these values are within the plot region? __ James Holtman What is the problem you are trying to solve? Executive Consultant -- Office of Technology, Convergys [EMAIL PROTECTED] (513) 723-2929 Anna H. Pryor [EMAIL PROTECTED]To: R-help mailing list [EMAIL PROTECTED] a.gov cc: Sent by: Subject: [R] lines and legend [EMAIL PROTECTED] ath.ethz.ch 07/01/2003 13:45 When I am trying to put a legend on a plot where I am using lines, R just ignores it. I can do it with boxplot or plot, but just not with lines. Am I doing something wrong? Maybe I am just making a mistake? Anna __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help -- Cheers, Kevin -- On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question. -- Charles Babbage (1791-1871) From Computer Stupidities: http://rinkworks.com/stupid/ -- Ko-Kang Kevin Wang Master of Science (MSc) Student SLC Tutor and Lab Demonstrator Department of Statistics University of Auckland New Zealand Homepage: http://www.stat.auckland.ac.nz/~kwan022 Ph: 373-7599 x88475 (City) x88480 (Tamaki) __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] lines and legend
Anna, I found this quite useful in positioning a legend: plot(1:10, 1:10) legend(locator(1), A legend) Now, go to the plot window and click your left mouse where you want the upper left corner of the legend to appear. Ithink, this should work no matter what your coordinate system is. Hope this helps, Andy __ Andy Jaworski Engineering Systems Technology Center 3M Center, 518-1-01 St. Paul, MN 55144-1000 - E-mail: [EMAIL PROTECTED] Tel: (651) 733-6092 Fax: (651) 736-3122 |-+ | | Anna H. Pryor | | | [EMAIL PROTECTED]| | | a.gov | | | Sent by: | | | [EMAIL PROTECTED]| | | ath.ethz.ch | | || | || | | 07/01/2003 12:45 | | || |-+ -| | | | To: R-help mailing list [EMAIL PROTECTED] | | cc: | | Subject: [R] lines and legend | -| When I am trying to put a legend on a plot where I am using lines, R just ignores it. I can do it with boxplot or plot, but just not with lines. Am I doing something wrong? Maybe I am just making a mistake? Anna __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help