Carissa Romero
Carissa Romero

Reputation: 23

Heatmap colors in R

I am trying to replicate the pictured color palette 1 from Matlab in r.

This is the code I have so far:

levelplot(rdm[,nrow(rdm):1], col.regions =colorRampPalette(c("Blue", "green", "yellow")) )

But the colors are not quite right.

Upvotes: 2

Views: 210

Answers (1)

jared_mamrot
jared_mamrot

Reputation: 26505

One potential solution is to use the colorRamps package, e.g. with blue2green2red()

install.packages("colorRamps")
library(colorRamps)
image(matrix(1:400, 20), col = blue2green2red(500)[100:400])

Created on 2021-08-31 by the reprex package (v2.0.1)

Or, with matlab.like():

image(matrix(1:1000, 20), col = matlab.like(100)[10:70])

example_2.png

These aren't exactly the same as your image, but I think they're pretty close. Does this solve your problem?

Upvotes: 2

Related Questions