Cable, Samuel B Civ USAF AFMC AFRL/RVBXI
2009-Apr-08 15:38 UTC
[R] vectors on top of contours, and lattice
OK, I needed to plot a set of vectors on top of a contour plot. I figured out a way to do this. I create a panel function that calls "larrows()" with arguments constructed from my vector data. Then, when I go to do the contour plot, I call contourplot() with the "panel" argument set to point to my newly created panel function. So far, so good. Now, I need to do a series of contour plots, each overlaid with a different set of vectors. I can call contourplot(z~x*y,...) but now I'm stuck, because each contour plot will be overlaid with the *same* vector plot. This won't work because each set of contoured data has its own particular set of associated vector data. (BTW, I am not doing gradients here. The vector data is its own entity, not derivable from the contoured data.) Can I somehow define a whole series of panel functions and coax contourplot() to choose the right one for each of its plots? Or do I have to revise my entire approach here? Thanks! --Sam [[alternative HTML version deleted]]
On 4/8/09, Cable, Samuel B Civ USAF AFMC AFRL/RVBXI <Samuel.Cable at hanscom.af.mil> wrote:> OK, I needed to plot a set of vectors on top of a contour plot. I > figured out a way to do this. I create a panel function that calls > "larrows()" with arguments constructed from my vector data. Then, when > I go to do the contour plot, I call contourplot() with the "panel" > argument set to point to my newly created panel function. > > > > So far, so good. > > > > Now, I need to do a series of contour plots, each overlaid with a > different set of vectors. I can call contourplot(z~x*y,...) but now > I'm stuck, because each contour plot will be overlaid with the *same* > vector plot. This won't work because each set of contoured data has its > own particular set of associated vector data. (BTW, I am not doing > gradients here. The vector data is its own entity, not derivable from > the contoured data.) Can I somehow define a whole series of panel > functions and coax contourplot() to choose the right one for each of its > plots? Or do I have to revise my entire approach here?See ?packet.number for one approach. This should allow you to extract the correct component of the vector data inside the panel function. -Deepayan
Apparently Analagous Threads
- need help with ordering of plots
- : (Lattice): Overlaying more than one trend surface using contourplot() and wireframe()
- overlay xyplot on contourplot in lattice in R
- contourplot:how to get it to label all contours like 'contour'
- weird error with contourplot