Skip to content

Could geom_histogram _not_ draw the colour outline where ymax = 0? #6627

@davidhodge931

Description

@davidhodge931
library(tidyverse)

#output currently like this for 0's
p <- palmerpenguins::penguins |>
  ggplot() +
  geom_histogram(
    aes(x = flipper_length_mm),
    colour = "orange",
    bins = 50,
  )

p
#> Warning: Removed 2 rows containing non-finite outside the scale range
#> (`stat_bin()`).

#would prefer the 0's looked like this
layer_data(p) |> 
  filter(ymax != 0) |> 
  ggplot() +
  geom_rect(
    aes(xmin = xmin, xmax = xmax, ymin = ymin, ymax = ymax),
    colour = "orange", 
    ) +
  labs(x = "flipper_length_mm", y = "count")
#> Warning: Removed 2 rows containing non-finite outside the scale range
#> (`stat_bin()`).

Created on 2025-09-19 with reprex v2.1.1

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