简体   繁体   中英

How interpret gray fields of grid produced by geom_tile?

I have produced a grid using <geom_tile()> and I am at a loss with how to interpret the gray fields. The scaling is set at viridis, meaning, the colour of the field should vary between blue and yellow. So: How do I interpret gray fields or what type of value do they represent respectively. It further appears, that the number of gray fields changes, as I change the number of grid points. Below are two images: One represents the Hovmöllerplot with a high resolution grid (lots of latitude-time bands), whereas the other represents a Hovmöllerplot with a low resolution grid (few latitude-time bands).

Grid with low resolution

1个

Grid with high resolution

2个

I was expecting the colour of the grid points to range between blue and yellow or to be empty, in the case of NA.

Those are NA's. You could filter them out if you don't want them shown.

df1 <- data.frame(x = 1:4, z = c(1:2, NA_real_, 4))

ggplot(df1, aes(x, 1, fill = z)) +
  geom_tile() +
  scale_fill_viridis_c()

在此处输入图像描述

ggplot(subset(df1, !is.na(z)), aes(x, 1, fill = z)) +
  geom_tile() +
  scale_fill_viridis_c()

在此处输入图像描述

To answer your question in the comment:

The white boxes are simply the background of your plot. You can even see the grid lines. There are no values to plot there. NA values correspond to missing values in your data (having actually NA in a cell). Non existing values are not plotted.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM