R + ggplot: coordinate transformations and geom_fill

The following code works well:

p <- ggplot(df,aes(x=x,y=y))
p <- p + geom_tile(aes(fill=z))
p

It depicts a nice heatmap. It dfcontains xand y, created using expand.grid()and z, which contains a value in each ( x, y) coordinate.

This code, on the other hand

p <- ggplot(df,aes(x=x,y=y))
p <- p + coord_map(project="lagrange")
p <- p + geom_tile(aes(fill=z))
p

draws nothing at all (and draws nothing with all the coordinate transformations I tried). I understand that Coord_Map works with x and y data, and the fill must be drawn on top of the transformed coordinates. However, this should be erroneous, since nothing is displayed after the coordinates have been matched with the new frame.

, : , ? - .frame df?

+3
1

, , , , . .

vol.m <- melt(volcano)

#points & cartesian
p <- ggplot(vol.m, aes(X1, X2, color = value)) + geom_point()
#points and map
p + coord_map()

#hex & cartesian
p <- ggplot(vol.m, aes(X1, X2, fill = value)) + geom_hex(stat = "identity")
#hex & map
p + coord_map

, geom_tile(), , , . , . , , , .

Edit: , " ", . , , , -, . , ggplot2 "" , .

+1

Source: https://habr.com/ru/post/1760376/


All Articles