Skip to content

Point symbols do not appear in the legend [geom_sf] #3572

Closed

Description

@kadyb

I chose point symbols, they appeared on the map, but didn't appear in the legend.

library("sf")
library("ggplot2")
df = data.frame(x = 1:2, y = 1:2, val = 3:4, shape = factor(1:2))
df = st_as_sf(df, coords = c("x", "y"), crs = 27700)

ggplot(df) +
   geom_sf(aes(color = val, shape = shape))

Imgur

Activity

  1. clauswilke commented on Oct 16, 2019

    @clauswilke
    Member

    Apparently the legend type is hardcoded and is not auto-detected:

    legend = if (is.character(show.legend)) show.legend else "polygon",

    Manually setting it to "point" works, but if we could add auto-detection that would be great.

    library("sf")
    #> Linking to GEOS 3.7.2, GDAL 2.4.2, PROJ 5.2.0
    library("ggplot2")
    df = data.frame(x = 1:2, y = 1:2, val = 3:4, shape = factor(1:2))
    df = st_as_sf(df, coords = c("x", "y"), crs = 27700)
    
    ggplot(df) +
      geom_sf(aes(color = val, shape = shape), show.legend = "point")

    Created on 2019-10-16 by the reprex package (v0.3.0)

  2. clauswilke commented on Dec 6, 2019

    @clauswilke
    Member

    With current ggplot2 master:

    library("sf")
    #> Linking to GEOS 3.7.2, GDAL 2.4.2, PROJ 5.2.0
    library("ggplot2")
    df = data.frame(x = 1:2, y = 1:2, val = 3:4, shape = factor(1:2))
    df = st_as_sf(df, coords = c("x", "y"), crs = 27700)
    
    ggplot(df) +
      geom_sf(aes(color = val, shape = shape))

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

  3. lock commented on Jun 24, 2020

    @lock

    This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/

  4. locked and limited conversation to collaborators on Jun 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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