[R] Control color palette and legend in filled.contour

Karline Soetaert Karline.Soetaert at nioz.nl
Fri Sep 19 13:01:56 CEST 2014


Thiago,

This will not be simple using filled.contour, as this changes the layout from the figure.
You might try the function image2D from plot3D:

require(plot3D)
par(mfrow = c(2, 1))
par(mar = c(0, 4, 4, 2))
plot(0, axes = FALSE, frame.plot = TRUE)   # upper plot
par(mar = c(4, 4, 0, 2))
Col <- ramp.col(c("blue", "red"))
image2D(z = volcano, col = Col, xlab = "", contour = TRUE,
  colkey = list(side = 1, length = 0.5))


Hope it helps,

Karline Soetaert

>Original Message: 1
>Date: Wed, 17 Sep 2014 01:53:05 -0700
>From: "Thiago V. dos Santos" <thi_veloso at yahoo.com.br>
>To: "r-help at r-project.org" <r-help at r-project.org>
>Subject: [R] Control color palette and legend in filled.contour
>Message-ID:
>	<1410943985.1852.YahooMailNeo at web121903.mail.ne1.yahoo.com>
>Content-Type: text/plain; charset="UTF-8"
>>Dear all,

>I am having some difficulties trying to control color palette and legend of a filled.countour plot. 
>
>Basically, I am plotting volumetric soil moisture which ranges from 0 to 1 (although the data excerpt I'm providing here ranges from 0 to 0.4, my complete dataset ranges from 0 to 1). Low values mean dry soil and higher values denote wet soil.
>
>Instead of the default color palette, I would like to set a 'red to blue' palette with legend ranging from 0 (red) to 1 (blue). My final goal is to achive a color palette and legend similar to this figure: https://imageshack.com/i/exmVz5QSp. 
>
>A sample of my data (as well as an attemptive plot) can be reproduced with this code:
>....
>>>>



More information about the R-help mailing list