[R] Draw a circle on a filled.contour() plot
Duncan Murdoch
murdoch at stats.uwo.ca
Sun Dec 17 16:04:37 CET 2006
On 12/17/2006 9:31 AM, Webmaster wrote:
>> The output produced by 'filled.contour' is actually a combination
>> of two plots; one is the filled contour and one is the legend.
>> Two separate coordinate systems are set up for these two plots,
>> but they are only used internally - once the function has
>> returned
>> these coordinate systems are lost. If you want to annotate the
>> main contour plot, for example to add points, you can specify
>> graphics commands in the 'plot.axes' argument. An example is
>> given below.
>
> Thanks!
>
> I now have another question (hopefully the last) for which I couldn't
> find an answer in the mailing-list archives: how can I get rid of the
> color key on the contour.filled() plot? I that question, unanswered,
> in a post one year ago on this same list, so I hope it's by any mean
> possible... (I think it's possible to change the code completely and
> use image(), but it's much less pretty).
I don't see any option in there, so you might have to write your own
version to do it. The source for the regular function is in
http://svn.r-project.org/R/trunk/src/library/graphics/R/filled.contour.R
and the part that plots the key is
## Plot the 'plot key' (scale):
mar <- mar.orig
mar[4] <- mar[2]
mar[2] <- 1
par(mar = mar)
plot.new()
plot.window(xlim=c(0,1), ylim=range(levels), xaxs="i", yaxs="i")
rect(0, levels[-length(levels)], 1, levels[-1], col = col)
if (missing(key.axes)) {
if (axes)
axis(4)
}
else key.axes
box()
if (!missing(key.title))
key.title
You'd probably also want to change the layout, because you won't want
the blank space there. Or possibly you could get the results you want
from contour(), which doesn't plot the scale.
Duncan Murdoch
More information about the R-help
mailing list