[R] contour(): lines & labels in different colours?

Peter Ehlers ehlers at ucalgary.ca
Sun Nov 22 22:57:20 CET 2009


Hi Ted,

This won't solve your problem, but a small improvement might
be to place the labels over the lines rather than the other
way around. It will definitely avoid putting red lines over
black ones:

x <- -6:16
z <- outer(x,x)
contour(z, labels="", col=2)
contour(z, lty=0, labcex=1, add=TRUE)

Cheers,
Peter


(Ted Harding) wrote:
> Greetings, All!
> I want to draw contour lines in red, using contour(), but also
> have the contour labels (for the level-values) in black so that
> they will stand out against a coloured background already generated
> using filled.contour() (the background shades from green at low
> levels of "risk" to red at high levels).
> 
> In any case, contour labels in red are already somewhat inconspicuous
> with contour lines in red, regardless of background.
> 
> I see nothing in ?contour nor in ?par about this.
> 
> One way to approach it could be to first draw the labelled contours
> in black, and then overlay by re-drawing (with out labels) in red.
> This would sort-of work, but the red contour lines would then cut
> through the black numbers, which is somewhat undesirable. Also
> (I've tried it) you can get show-through along the contour lines
> from the black layer, which is nasty.
> 
> Any suggestions?
> 
> With thanks,
> Ted.
> 
> --------------------------------------------------------------------
> E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
> Fax-to-email: +44 (0)870 094 0861
> Date: 22-Nov-09                                       Time: 17:06:08
> ------------------------------ 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.
> 
>




More information about the R-help mailing list