Home > Back-end >  Remove ticks / tiny white line from colorbar ggplot2
Remove ticks / tiny white line from colorbar ggplot2

Time:02-03

how to remove that white line from a ggplot2 colourbar?

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

generates this plot

enter image description here

But if you zoom in the legend, you will see tiny annoying white lines:

enter image description here

How can I remove them? Thanks

CodePudding user response:

You can set the ticks.colour= within guide_colorbar() by referencing via guides()... here ya go:

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

enter image description here

And to remove them, set the color to NA:

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

enter image description here

  •  Tags:  
  • Related