0

By default, ggplot2 shows two ticks on each side of the legend (see image below). Is there a way to show a full line instead of separated ticks?

Reprex with default ticks of ggplot2

library(ggplot2)

df <- data.frame(x = 1, y = 1:3, z = 1:3)

ggplot(df, aes(x, y)) + 
  geom_raster(aes(fill = z)) +
  scale_fill_continuous(guide = guide_colorbar(
                        ticks.colour = "red", 
                        ticks.linewidth = 2,
                        barwidth = 2
                        )
                      )

enter image description here

Desired result

enter image description here

rafa.pereira
  • 13,251
  • 6
  • 71
  • 109
  • 3
    Does this answer your question? [Continuous color bar with separators instead of ticks](https://stackoverflow.com/questions/62558043/continuous-color-bar-with-separators-instead-of-ticks). There are two (somewhat hackish) solutions in this post from a bit more than a year ago... I don't know of a better solution but would be interested in one!! – dario Oct 18 '21 at 15:21
  • 2
    Maybe you are looking for [guide_colorsteps()](https://ggplot2.tidyverse.org/reference/guide_coloursteps.html)? I haven't used it but look like that could be a place to start. – aosmith Oct 18 '21 at 15:38

0 Answers0