Skip to content

ggsave inproperly rendering geom_line with factored y-variable #4204

Closed
@MartinEarle

Description

@MartinEarle

Hi,

I have come across a strange issue with ggsave() where it does not properly render a line if the y-variable is factored. It looks to me like it is ignoring the factoring, and plotting as if it was unfactored. It looks like this behavior does not occur when factoring the x-variable. When I use graphic devices like png() I do not have the issue. I did not include ggsave() or png() in the reprex because there is nowhere for the files to save, of course, but I have attached the output of each method below it.

library(tidyverse)

mtcars %>% 
  mutate(mpg = factor(mpg)) %>% 
  ggplot(aes(disp, mpg)) +
    geom_line(group = 1)

Created on 2020-09-19 by the reprex package (v0.3.0)

ggsave():
ggplot_output

png():
png_output

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions