質問

Following up this question: pseudocolors in R I've found a way to create the pseudocolour images with a colour key. However, I'm stuck with adding some text to this key (e.g., "low", "mid", "high" along with tickmarks at the ends an in the middle).

The short version of the story (as an MWE), would be:

library(RColorBrewer)

pal <- colorRampPalette(brewer.pal(9, "YlOrBr"), space = 'rgb')(256)

layout(matrix(c(1,2), nrow = 1), widths = c(4,1), heights = c(4,4))
layout.show(2)

par(mar = c(0,0,0,0))
image(t(matrix(1:30, ncol = 1, nrow = 30)), 
     col = pal, xaxt = "n", yaxt = "n", frame.plot = FALSE)

par(mar = c(0,0.1,0,0))
image(t(matrix(1:30, ncol = 1, nrow = 30)), 
     col = pal, xaxt = "n", yaxt = "n", frame.plot = FALSE)

So the aim is to end tickmarks with text on the left part of the image.

Thanks in advance for any help!

役に立ちましたか?

解決

I didn't see the point of the layout but thought you could just increase your margin for the first image call and leave out the second one? You wanted "low", "mid", "high" along with tickmarks at the ends an[d] in the middle which I found confusing. Perhaps this will further the discussion:

layout(matrix(c(1,2), nrow = 1), widths = c(4,1), heights = c(4,4))
layout.show(2)

par(mar = c(0,0,0,2))
image(t(matrix(1:30, ncol = 1, nrow = 30)), 
     col = pal, xaxt = "n", yaxt = "n", frame.plot = FALSE)
axis(4, at=(30:1)/30, labels=1:30, cex.lab=0.6)

enter image description here

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top