Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing lines within filled.contour legend

Tags:

r

I might be missing something simple here... I can't find anyway to remove the lines that cross the legend differentiating different colours; following on the from the volcano topography example in ?filled.contour, I've got this:

x <- 10*1:nrow(volcano)
y <- 10*1:ncol(volcano)

filled.contour(x, y, volcano, color = terrain.colors,
   plot.title = title(main = "The Topography of Maunga Whau",
    xlab = "Meters North", ylab = "Meters West"),
    plot.axes = { axis(1, seq(100, 800, by = 100))
              axis(2, seq(100, 600, by = 100)) },
    key.title = title(main="Height\n(meters)"),
    key.axes = axis(2,
          labels=FALSE,
          at=FALSE,
          lty=NULL,
          tick=FALSE,
          col="white",
          col.ticks=NULL)
)
mtext(paste("filled.contour(.) from", R.version.string),side = 1, line = 4, adj = 1, cex = .66)

I've managed to remove all the labels and tick-marks from the axis, but the lines still exist (incidentally, the effect I'm trying to achieve is (I believe) the default in Matlab!)

like image 671
ChrisW Avatar asked Nov 09 '11 16:11

ChrisW


People also ask

What is the difference between filled contour and filled legend?

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.

How do you handle contour patches?

You can get a handle to contour patches by using contourm, contour3m, or contourfm. Location to place legend, specified as one of the following integers. Text to append to each entry in the legend, specified as a character vector or string scalar.

What is filled contour in AutoCAD?

.filled.contour is a ‘bare bones’ interface to add just the contour plot to an already-set-up plot region. It is is intended for programmatic use, and the programmer is responsible for checking the conditions on the arguments. filled.contour uses the layout function and so is restricted to a full page display.

How do I create a contour map?

Create a map axes object for the world. Display a contour plot using the raster data. Then, create a legend in the lower-right corner of the map. Specify the contour elevations as meters. Contour matrix, specified as a matrix with two rows. The first row represents longitude data and the second row represents latitude data.


1 Answers

If you examine the code for filled.contour you'll see this line:

rect(0, levels[-length(levels)], 1, levels[-1L], col = col)

that draws the color key rectangle. It's vectorized, so it's drawing each of the individual color boxes. The function rect accepts an argument border, which if you set to NA will omit the internal borders of the rectangles. So create your own version of the function and change this line to :

rect(0, levels[-length(levels)], 1, levels[-1L], col = col, border = NA)

or make it an argument, rather than hard coding. When I do this, I get the following graph:

enter image description here

like image 80
joran Avatar answered Sep 29 '22 06:09

joran