从 colorbar ggplot2 中删除刻度线/细白线

Remove ticks / tiny white line from colorbar ggplot2

如何从 ggplot2 颜色条中删除白线?

ggplot(faithfuld, aes(waiting, eruptions)) +
  geom_raster(aes(fill = density)) +
  scale_fill_gradientn(colours = terrain.colors(10))+
theme(legend.key.height=unit(2,"line"))

生成此图

但是如果你放大图例,你会看到微小的烦人的白线:

我怎样才能删除它们?谢谢

您可以通过 guides() 引用来在 guide_colorbar() 中设置 ticks.colour=... 在这里:

# where "plot" = your plot code...
plot + guides(fill=guide_colorbar(ticks.colour = "black"))

要删除它们,请将颜色设置为 NA:

plot + guides(fill=guide_colorbar(ticks.colour = NA))