[R] Labelling curves on graphs

(Ted Harding) Ted.Harding at manchester.ac.uk
Thu Jul 17 19:34:39 CEST 2008

On 17-Jul-08 02:32:41, Frank E Harrell Jr wrote:
> Barry Rowlingson wrote:
>> 2008/7/16 Ted Harding <Ted.Harding at manchester.ac.uk>:
>>> Hi Folks,
>>> I'd be grateful for good suggestions about the following.
>>> I'm plotting a family of (X,Y) curves (for different levels
>>> of another variable, Z): say 6 curves in all but could be
>>> more or less -- it's a rather variables situation.
>>> I'd like to label each curve with the value of Z that it
>>> corresponds to.
>>> But people out there must have faced it, and I'd be grateful
>>> for their own feedback from the coal-face!
>> Isn't this why we have colour vision? Just use 6 different colours
>> and a legend. Or use linestyles and colours. Trying to do neat
>> labelling along general lines like contour does is going to fail
>> in edge cases such as if two lines are very close together.
>> Contour can be fairly sure the lines will have sensible spacing
>> unless it's mapping cliffs.
>> I looked at the underlying C code for contour a while back with a
>> view to using the algorithms in another package, but I gave up
>> pretty quickly. The generated contour lines and labels are quite
>> beautiful, but the code gave me
>> a headache.
>> Barry
> Barry,
> Why use color when you can use black and label the curves where they
> are most separated?  This solves problems with color blindness,
> xeroxing, and faxing.
> Frank

[Also taking later postings into account]
Barry has a fair point, as far as it goes, but Frank's response is
an indicator of how far it can go. Colour is fine on a monitor screen,
provided there are only a few lines.

With up to 4 colours (say black, red, blue, green) you can get good
distinguishability between colours. More than that, and they can be
difficult to distinguish.

Also, I find I get "cross-reference overload" with as few as 4 colours,
and looking up the key gets distracting; much easier to let your eye run
along the curve to find its label).

In any case, in the case I have in hand, this is eventually getting
printed in black and white, so the colour solution would not be much
use! (Trying to distinguish lines printed in subtly different shades
of grey is a fruitless exercise).

The issue of curves which intersect each other is indeed tricky;
if colour is not practicable, then several labels per curve is
presumably the way to go.

Indeed, the case I'm looking at tends to have curves broken into
disjoint segments (a consequence of NA results for some ranges of
the variables) so the same issue can arise.

This has been an interesting and helpful discussion, and I'm grateful
to all participants.


E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 17-Jul-08                                       Time: 18:34:34
------------------------------ XFMail ------------------------------

More information about the R-help mailing list