Skip to content

Place the extreme ticks at the edge of the legend frame without extra padding #3350

@caijun

Description

@caijun

The following example is to illustrate my obsessive feature request. As you see, there is a small amount of padding between the first (or the last) legend tick and legend frame. How could I remove those paddings and make the first or the last legend ticks at the edge of legend frame?
Is there also an expand parameter available for colorbar scales?


Brief description of the problem

library(ggplot2)
p <- ggplot(mtcars, aes(hp, disp, color = mpg)) + 
  geom_point() + 
  scale_color_continuous(limits = c(10, 35),
                         breaks = seq(10, 35, by = 5),
                         guide = guide_colorbar(
                           direction = "horizontal",
                           title.position = "top", 
                           title.hjust = 0.5, 
                           ticks.colour = "white", 
                           frame.colour = "black", 
                           barwidth = 12)) + 
  theme(legend.position = "top")
p

Created on 2019-06-01 by the reprex package (v0.3.0)

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions