[R] combine trellis lattice contour plot with simple plot() points() and text() commands?

Duncan Mackay dulcalma at bigpond.com
Tue Jun 2 02:44:26 CEST 2015


Hi Ivo

If you want to add lines, text etc you can do that by a  lattice panel
function included in it would be panel.contour

something like (untested)

contourplot(...
                       panel = function(x,y, etc,...){
            
                                        panel.countorplot(x,y, etc)
 
                                       panel.lines(x,y,...)
                                       panel.text(....)
                                  }
)

and see also
library(lattice)
names(trellis.par.get())
and delve into the names that come up that are applicable

See the help page

? panel.lines which should cover most of what you need.
Remember that you may have to look at 
? grid::gpar for fine tuning of the arguments

Just finished a plot with panel.segments

panel.segments(xlocs - medsbar.len, meds,
               xlocs + medsbar.len, meds,
               lineend = 1, # grid gpar call for line ending
               lwd = 5,
               col = 2)

Duncan

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2351
Email: home: mackay at northnet.com.au

-----Original Message-----
From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of ivo welch
Sent: Tuesday, 2 June 2015 07:03
To: r-help
Subject: [R] combine trellis lattice contour plot with simple plot()
points() and text() commands?

can I add ordinary graphics commands to a contourplot?  my naive
attempts are telling me that plot.new() has not yet been called when I
try to add text(1,1,"hi") or points( c(0,1), c(1,0) )?

[or do I need to rewrite another contourplot with the old graphics
system.  the basics are probably looking at adjacent points,
pretending that they are linear, and mark where a line between them
intercepts the level, and then hope that some sanity prevents me from
connecting disconnected levels.  not my plan...]

----
Ivo Welch (ivo.welch at gmail.com)
http://www.ivo-welch.info/

______________________________________________
R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
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