Skip to content

linetype incorrectly renders in legend when drop=FALSE #6550

Closed as duplicate of#5728
@jnolis

Description

@jnolis

Hi!

When I use scale_linetype_manual to specify line types for different discrete levels, the legend in correctly renders. The dropped linetypes do show up in the legend but their squares are blank. This is using version 3.5.2. Thanks!

library(tidyverse)

df <- tibble(
  x = c(1,2,1,2), 
  y = c(0,1,1,0), 
  group = c("a","a","b","b") |> factor(levels = c("a","b","c"))
)

ggplot(df,aes(x=x,y=y,group=group,linetype=group)) + geom_line()+
  scale_linetype_manual(values=c("a"="solid","b"="dashed","c"="twodash"),drop=FALSE)
  
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