[R] adjusting levelplot color scale to data
baptiste auguie
baptiste.auguie at googlemail.com
Mon Nov 7 06:05:12 CET 2011
Hi,
Try specifying explicit break points together with their corresponding
colors using at and col.regions,
levelplot(m, at= unique(c(seq(-2, 0, length=100), seq(0, 10,
length=100))), col.regions = colorRampPalette(c("blue", "white",
"red"))(1e3))
HTH,
baptiste
On 7 November 2011 16:08, Lanna Jin <lannajin at gmail.com> wrote:
> Hi guys,
>
> I have a matrix with values varying from approximately -0.7 to 0.33 that I
> want to create a heatmap/levelplot with.
>
> When I execute the levelplot function for my matrix, I end up getting colors
> that are adjusted to the max and min rather than around 0. In other words,
> ideally I would like to have a color ramp that goes from red (negative
> number), to white (0), to blue (positive); however, right now the value 0 is
> in the blue.
>
> Any insight on how to address this problem?
>
> Thanks in advance!
>
> example...
> my matrix "y" looks something like this
> A B C
> D E
> row1 -0.5046406 -0.021579587 -0.4419101 -0.2999195330
> -0.4845047
> row2 -0.3070091 -0.059065936 0.3329806 -0.0519335420
> -0.5766368
> row3 -0.7271707 0.073282855 -0.3181990 -0.2485017700
> -0.5732781
> row4 0.3329806 -0.017762750 -0.1513197 -0.1016354970
> 0.2528442
>
> levelplot(y) yields a color scale from red (-0.8 to 0.2) to blue (0.2 to
> 0.4)
> I'd want the color scale to be from red (-0.8 to 0) to blue (0 to 0.4)
>
>
>
> -----
> Lanna
> --
> View this message in context: http://r.789695.n4.nabble.com/adjusting-levelplot-color-scale-to-data-tp3997342p3997342.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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