[R] plot symbol "+", but with variable bar lenghts

(Ted Harding) Ted.Harding at manchester.ac.uk
Thu Sep 9 09:36:40 CEST 2010


On 09-Sep-10 06:41:34, Rainer Machne wrote:
> Hi,
> does anybody know of some plotting function or an easy way to 
> generate "+" symbols with individually settable bar lengths?
> I tried just combining "|" and "-" as pch and setting the size via cex,
> but that doesn't really work since the two symbols have different
> default lengths. Is there a horizontal | or a longer "-" available?
> 
> Thanks,
> Rainer

I tried this using pch="_" for the horizontal bar, but it is only
about half the length of the pch="|" bar. However, compared with the
same plot using pch="+", at least the resulting cross went through
the centre of the "+" cross. To increase the length of the "_" to
equal that of the "|" would require some empirical fiddling with
'cex=..." and would increase the thickness of the "_".

I don't know of any way to create a symbol using drawing commands,
and assigning the result to a "character" which could be evoked
using 'pch="..."', which would seem to be the sort of thing you
would like to be able to do. This could be a useful extension to
the plot() function and friends.

You can of course define an auxiliary function, say mycross(),
on the lines of

  mycross <- function(x,y,L,U,R,D){
    lines(c(x,x-L),c(y,y))
    lines(c(x,x),c(y,y+U))
    lines(c(x,x+R),c(y,y))
    lines(c(x,x),c(y,y-D))
  }

but then you would have to explicitly apply this to the data,
rather than delegate it to the plot() function's pch option.

Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 09-Sep-10                                       Time: 08:36:36
------------------------------ XFMail ------------------------------



More information about the R-help mailing list