[R] Labelling curves on graphs

From: Ted Harding <Ted.Harding_at_manchester.ac.uk>
Date: Wed, 16 Jul 2008 21:17:16 +0100 (BST)

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.

The problem is that the layout (shapes, spacings, ranges of X over which non-NA values of Y get plotted) of the curves are very variable, and somewhat unpredictable beforehand.

Of course one could simply wait until the graph was done, and then by hand position one's labels to the best effect. That, given time, is on a certain sense the optimum solution. But I'd like to be able to do a satisfactory job automatically, and quickly!

This is the sort of problem already solved, in one particular way, in contour(). But here the curves are broken at the labels and the labels are centred on the curves (though nicely aligned with the curves).

It might be satisfactory for me to place each label so that its baseline is on its curve, thus without overlaying the curve with the text. So maybe a "displaced" analogue of the way contour() does it (including alignment of the text) may be OK.

Anothe possibility, for instance, is to draw lines from the ends of the curves to antries in a plotted table of Z-values. This could end up looking very untidym, though.

I grant that this is a vague query. I'm still trying to form a clear view of how it ought to be approached; and I don't have R code to refer to and experiment with (that of contour() is hidden in its "method").

But people out there must have faced it, and I'd be grateful for their own feedback from the coal-face!

With thanks,

E-Mail: (Ted Harding) <Ted.Harding_at_manchester.ac.uk> Fax-to-email: +44 (0)870 094 0861
Date: 16-Jul-08                                       Time: 21:17:13
------------------------------ XFMail ------------------------------

R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed 16 Jul 2008 - 20:23:42 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 17 Jul 2008 - 00:32:07 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive