Re: [R] Legend placement in barplot?

2004-11-04 Thread Dan Bolser
On Wed, 3 Nov 2004, Marc Schwartz wrote:

On Wed, 2004-11-03 at 09:55, Dan Bolser wrote:
 This has been asked before, but all the answers are hidiously complex.
 
 The
 
 legend.text=TRUE 
 
 option of barplot is almost exactly what I need, except I need a
 
 legend.placement='tl'
 
 (top left) option. This option would be in contrast to the default
 placement which we could call 'tr' (top right).
 
 Anyone know how to edit the barplot code to make this change? Could
 someone like me work out how to do this?
 
 Cheers,
 Dan.

Dan,

Do not edit the barplot() code. Use the legend() function instead, which
enables you to specify the x,y coordinates of the upper left hand corner
of the legend box. See ?legend

Thing is I need to pass legend the correct groups and correct plotting
colors and correct XY position relative to my data. All these things are
already known by the barplot function, and used to draw a beautiful
legend.

The fact that this legend can only appear in the upper right hand corner
is surly a bug worthy of changing the code for?


A fair number of the questions that you have had regarding graphics are
covered in Chapter 12 Graphical Procedures in An Introduction to R:

http://cran.r-project.org/doc/manuals/R-intro.pdf

which is included with the R installation.

Another online resource for some graphics assistance would be R News
Volume 3 Number 2 for October 2003, which has an article on R's base
graphics in the R Help Desk section:

http://cran.r-project.org/doc/Rnews/Rnews_2003-2.pdf

Thanks for the links

Notwithstanding all of that, searching the r-help archives is yet
another terrific online (and free) resource that you _should_ avail
yourself of.


Quoting me... This has been asked before, but all the answers are
hidiously complex.



HTH,

Marc Schwartz



__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Legend placement in barplot?

2004-11-04 Thread Dan Bolser
On Wed, 3 Nov 2004, Gabor Grothendieck wrote:

Dan Bolser dmb at mrc-dunn.cam.ac.uk writes:

: 
: This has been asked before, but all the answers are hidiously complex.
: 
: The
: 
: legend.text=TRUE 
: 
: option of barplot is almost exactly what I need, except I need a
: 
: legend.placement='tl'
: 
: (top left) option. This option would be in contrast to the default
: placement which we could call 'tr' (top right).
: 
: Anyone know how to edit the barplot code to make this change? Could
: someone like me work out how to do this?
: 
: Cheers,
: Dan.


Check out gplots::smartlegend (in the R 2.0.0 gregmisc bundle).


This works great, but like the (smart)legend function, fill=true appears
to be giving me only black boxes.

Here is what I add..

smartlegend(x=left,y=top,
c(PDB,MSD),
fill=TRUE,
col=c(red,blue)
   )

The result is two black boxes! I tried swapping the order of the color and
fill options, but to the same effect.

I got round the problem by using...

smartlegend(x=left,y=top,
c(PDB,MSD),
col=c(red,blue),
lwd=5
)

Not quite the same, but good enough.


One other thing (while I am generally complaining), the legend dosn't
scale correctly as I change the image size with the mouse. All the other
aspects of the barplot scale correctly. If I redraw the legend after
changing the size it is scaled correctly, suggesting that this problem
isn't fundamental, but is a bug in the implementation of legend.




__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Legend placement in barplot?

2004-11-04 Thread F Z
You can use locator()  nested within legend()
i.e.
plot(YourVariable)
legend(locator(1),legend=Your Legend)
Once you call this command it will display Your Legend in the place where 
you left clicked your mouse.  Beware that, as described in the documentation 
...'locator' is only supported on screen devices such as 'X11','windows' 
and 'quartz'.  On other devices the call will do nothing

Altrenativelly you can pass the exact coordinates of the position where you 
want the legend, instead of using locator
i.e.

plot(YourVariable)
x-list(x=-91.76781, y=46.87375)
legend(x,legend=Your Legend)
I hope that this helps
Francisco
From: Gabor Grothendieck [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: Re: [R] Legend placement in barplot?
Date: Wed, 3 Nov 2004 18:48:48 + (UTC)
Dan Bolser dmb at mrc-dunn.cam.ac.uk writes:
:
: This has been asked before, but all the answers are hidiously complex.
:
: The
:
: legend.text=TRUE
:
: option of barplot is almost exactly what I need, except I need a
:
: legend.placement='tl'
:
: (top left) option. This option would be in contrast to the default
: placement which we could call 'tr' (top right).
:
: Anyone know how to edit the barplot code to make this change? Could
: someone like me work out how to do this?
:
: Cheers,
: Dan.
Check out gplots::smartlegend (in the R 2.0.0 gregmisc bundle).
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! 
http://www.R-project.org/posting-guide.html
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Legend placement in barplot?

2004-11-04 Thread Dan Bolser
On Fri, 5 Nov 2004, F Z wrote:

You can use locator()  nested within legend()
i.e.

plot(YourVariable)
legend(locator(1),legend=Your Legend)

Once you call this command it will display Your Legend in the place where 
you left clicked your mouse.  Beware that, as described in the documentation 
...'locator' is only supported on screen devices such as 'X11','windows' 
and 'quartz'.  On other devices the call will do nothing


Altrenativelly you can pass the exact coordinates of the position where you 
want the legend, instead of using locator
i.e.

plot(YourVariable)
x-list(x=-91.76781, y=46.87375)
legend(x,legend=Your Legend)

I hope that this helps

Francisco

Thanks very much for the tips. Basically I want a very flexible solution
that lets me punch the numbers in - take a look at the result and then
immediatly dump a .ps / .eps / .png format of what I saw. The result
should be very quickly 'publication quality' (whatever that is). 

The problem with locator is that I don't know how to make it work with
postscript, and I don't want to find out. I don't want to have to probe my
figure for the coordinates every time I change the data in my figure. I am
happy saying something like 'oh, top left is bad, lets use top right' -
done.

smartlegend is almost there, I just think barplot should support exactly
the same functionality as smartlegend. This would save me the hassle of
creating a new legend every time my data changes, matching up colors and
names.

I am sure their is a way to code this, but I don't want to write code - at
least not code that I have to look at when what I want to see is my data. 



From: Gabor Grothendieck [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: Re: [R] Legend placement in barplot?
Date: Wed, 3 Nov 2004 18:48:48 + (UTC)

Dan Bolser dmb at mrc-dunn.cam.ac.uk writes:

:
: This has been asked before, but all the answers are hidiously complex.
:
: The
:
: legend.text=TRUE
:
: option of barplot is almost exactly what I need, except I need a
:
: legend.placement='tl'
:
: (top left) option. This option would be in contrast to the default
: placement which we could call 'tr' (top right).
:
: Anyone know how to edit the barplot code to make this change? Could
: someone like me work out how to do this?
:
: Cheers,
: Dan.


Check out gplots::smartlegend (in the R 2.0.0 gregmisc bundle).

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! 
http://www.R-project.org/posting-guide.html

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Legend placement in barplot?

2004-11-03 Thread Marc Schwartz
On Wed, 2004-11-03 at 09:55, Dan Bolser wrote:
 This has been asked before, but all the answers are hidiously complex.
 
 The
 
 legend.text=TRUE 
 
 option of barplot is almost exactly what I need, except I need a
 
 legend.placement='tl'
 
 (top left) option. This option would be in contrast to the default
 placement which we could call 'tr' (top right).
 
 Anyone know how to edit the barplot code to make this change? Could
 someone like me work out how to do this?
 
 Cheers,
 Dan.

Dan,

Do not edit the barplot() code. Use the legend() function instead, which
enables you to specify the x,y coordinates of the upper left hand corner
of the legend box. See ?legend

A fair number of the questions that you have had regarding graphics are
covered in Chapter 12 Graphical Procedures in An Introduction to R:

http://cran.r-project.org/doc/manuals/R-intro.pdf

which is included with the R installation.

Another online resource for some graphics assistance would be R News
Volume 3 Number 2 for October 2003, which has an article on R's base
graphics in the R Help Desk section:

http://cran.r-project.org/doc/Rnews/Rnews_2003-2.pdf

Notwithstanding all of that, searching the r-help archives is yet
another terrific online (and free) resource that you _should_ avail
yourself of.

HTH,

Marc Schwartz

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Legend placement in barplot?

2004-11-03 Thread Gabor Grothendieck
Dan Bolser dmb at mrc-dunn.cam.ac.uk writes:

: 
: This has been asked before, but all the answers are hidiously complex.
: 
: The
: 
: legend.text=TRUE 
: 
: option of barplot is almost exactly what I need, except I need a
: 
: legend.placement='tl'
: 
: (top left) option. This option would be in contrast to the default
: placement which we could call 'tr' (top right).
: 
: Anyone know how to edit the barplot code to make this change? Could
: someone like me work out how to do this?
: 


In package gplots (in bundle gregmisc in R 2.0.0) there is smartlegend.

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Legend placement in barplot?

2004-11-03 Thread Gabor Grothendieck
Dan Bolser dmb at mrc-dunn.cam.ac.uk writes:

: 
: This has been asked before, but all the answers are hidiously complex.
: 
: The
: 
: legend.text=TRUE 
: 
: option of barplot is almost exactly what I need, except I need a
: 
: legend.placement='tl'
: 
: (top left) option. This option would be in contrast to the default
: placement which we could call 'tr' (top right).
: 
: Anyone know how to edit the barplot code to make this change? Could
: someone like me work out how to do this?
: 
: Cheers,
: Dan.


Check out gplots::smartlegend (in the R 2.0.0 gregmisc bundle).

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html