Skip to content
Back to formatted view

Raw Message

Message-ID: <CANLFJPrKKkwEaSOz=Dqc3MjuX-ng+pfd1F5UYRa5RDaT7+1chA@mail.gmail.com>
Date: 2011-11-07T05:05:12Z
From: Baptiste Auguie
Subject: adjusting levelplot color scale to data
In-Reply-To: <1320635324457-3997342.post@n4.nabble.com>

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.
>