[R] labels outside plotting region

Arne Mueller a.mueller at icrf.icnet.uk
Sun Mar 10 01:28:55 CET 2002


Hello and thanks a lot for your quick reply.

Robert Gentleman wrote:
> 
> On Sat, Mar 09, 2002 at 10:38:57PM +0000, Arne Mueller wrote:
> > Hello,
> >
> > I've just started R, and I'm getting a bit mad using it. I've managed to
>  Well, you could stop -- we provide full refunds and things like Excel
>  are supposedly easy to use :-).

I've tried Excel, Cricket Graph for Mac, SigmaPlot and Gnuplot. Either
of these programs does what I realy want, and most of them fail to write
proper encapsulated postscript (excpet for gnuplot off course). I'm
writing up my thesis and take the opportunity to learn a little bit
about R - I'm sure it'll be very useful for me once I've learned the
basic stuff.
 
> > produce a barplot with the labels for the ytick marks placed
> > horizontally (perpendicular to the y-axis) usiing par(las=1). The
> > problem is that most of my labels are in part beyond the plotting area
> > because they are rather long (e.g. "H. sapiens", "D. melanogaster" ...).
> >
> > What is the easiest way to solve this problem, can I (somehow)
> > re-scale
>  The easiest solution is to use shorter labels :-). The second easiest
>   might be to use the mar option, ?par will give you the man page
>   for all the par options. This will probably look funny. You can also shring
>   the font etc either via cex or directly.

Ahh, the mar option seems to be exaclty what I'm looking for, just tired
it (successfully ;-). Very good!

But now I've another problem - thelegend of the plot. By default it's
placed in the upper right corner, and I've managed to place it where I
want (e.g. just below the plot using 'horiz'). Unfortunately I cannot
get the sourrounding box for the legend and the small coloured boxes for
the legend, alothough I'm using the 'filled' option.

>   If you include an example that the rest of us can run that
>   reproduces your problem it makes it a little easier to figure out
>   just what you want.

Ok, I'm not usre what's the best way to send thge code + data but here's
basically what I've done:

mx is my data matrix from which I'd like to produce a stacked bar chart.

> mx
             H. sapiens C. elegans D. melanogaster S. cerevisiae E. coli
structure    "39"       "30"       "31"            "31"          "47"   
function     "38"       "28"       "29"            "33"          "38"   
any homology "15"       "19"       "12"            "13"          " 8"   
non globular " 2"       " 6"       " 8"            " 5"          " 2"   
orphan       " 6"       "17"       "20"            "18"          " 5"   
             M. tuberculosis B. subtilis V. cholerae A. pernix P.
horikoshii
structure    "43"            "46"        "45"        "32"     
"41"         
function     "26"            "33"        "36"        "16"     
"25"         
any homology "15"            "10"        " 8"        " 7"     
"20"         
non globular " 7"            " 3"        " 3"        "12"      "
5"         
orphan       " 9"            " 8"        " 8"        "33"      "
9"         
             M. jannaschii A. aeolicus H. pylori M. genitalium
structure    "44"          "49"        "44"      "47"         
function     "27"          "33"        "36"      "44"         
any homology "13"          " 5"        "16"      " 6"         
non globular " 4"          " 4"        " 1"      " 1"         
orphan       "12"          " 9"        " 3"      " 2"    


these are the colors of each of the 'stacked' bars per row
> colors  
[1] "red"    "blue"   "green"  "yellow" "gray"  

> par(mar=c(7,7,0,1), las = 1, xpd=TRUE)
> legend(-10, -3, legend.text, fill=colors, y.intersp=2, horiz=TRUE)
> barplot(mx, beside=FALSE, horiz=TRUE, axes=TRUE, axisnames=TRUE, xlab="fraction of proteome [% of residues]", col=colors)

The legend labels appear correctly but the symbols don't (no symbols at
all). I thought if the filled argument is set small squares are
displayed ... . The problem is that one does not know which bar colours
belongs to which category.

I'm using R 1.1.1 under Suse linux 7.1.

Maybe you've got an idea what goes wrong here. Thanks again for a lot
for your kind help.

	regards,

	Arne

-- 
Arne Mueller
Biomolecular Modelling Laboratory
Imperial Cancer Research Fund
44 Lincoln's Inn Fields
London WC2A 3PX, U.K.
phone : +44-(0)207 2693405      | fax :+44-(0)207-269-3534
email : a.mueller at icrf.icnet.uk | http://www.bmm.icnet.uk
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list