Matze
Matze

Reputation: 13

How do I match colours in two different image.plots in R?

Let`s assume I have two different plots with similar dimensions:

First:

library(fields)
x <- 1:10
y <- 1:15
z <- outer(x, y, "+")
image.plot(x, y, z)

Second:

library(fields)
x <- 5:15
y <- 5:20
z <- outer(x, y, "+")
image.plot(x, y, z)

I`d like to match the color gradients of both plots with yellow at z=15.

I appreciate your help

Upvotes: 1

Views: 145

Answers (1)

MrFlick
MrFlick

Reputation: 206197

If you want to use the same color breaks for each of your plots, you should manually specify them. For example

image.plot(x, y, z, breaks=seq(0, 35, length.out=65), col=rainbow(64))

This will fix the color scale from 0 to 35. Or you could set whatever range you like.

Upvotes: 1

Related Questions