user2015601
user2015601

Reputation:

No effect of colorkey.space attribute in lattice's levelplot function

I try to draw the color key on the left side, but when adding the attribute colorkey.space="left" to the levelplot function, the color key does not move at all but is still on the right (default) side. Anyone knows if this is a bug, or am I missing something?

Here is a excerpt from the help function of levelplot:

colorkey - logical specifying whether a color key is to be drawn alongside the plot, or a list describing the color key. The list may contain the following components:

space: location of the colorkey, can be one of "left", "right", "top" and "bottom". Defaults to "right".

Note: colorkey=FALSE works perfectly fine

Upvotes: 0

Views: 480

Answers (1)

mnel
mnel

Reputation: 115425

The wording implies you need to pass a list with components such as space

eg

 colorkey = list(space = 'left')

Using a modification example from ?levelplot

x <- seq(pi/4, 5 * pi, length.out = 100)
y <- seq(pi/4, 5 * pi, length.out = 100)
r <- as.vector(sqrt(outer(x^2, y^2, "+")))
grid <- expand.grid(x=x, y=y)
grid$z <- cos(r^2) * exp(-r/(pi^3))
levelplot(z~x*y, grid, cuts = 50, scales=list(log="e"), xlab="",
          ylab="", main="Weird Function", sub="with log scales",
          colorkey = list(space = 'left')

enter image description here

Upvotes: 2

Related Questions