Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected gray legend labels when factor was created within categories of another factor. #425

Open
michaeldgarber opened this issue May 26, 2022 · 0 comments

Comments

@michaeldgarber
Copy link

michaeldgarber commented May 26, 2022

library(mapview)
library(tidyverse)
library(sf)

Possibly related to #323 and #336

Hi Tim and all,
I'd like to visualize a three-level factor within levels of another three-level factor. Within the first level of the first factor variable, the legend appears as expected. Within the other two levels, however, the vector data renders with the expected colors, but the legend labels are all gray.

I don't get the issue when I convert the second-level factor (n_types_by_founded_year_tertile, below) to character, but then the legend labels don't print in the correct order.

Thanks as always for the great package-

breweries_wrangle = mapview::breweries %>%
  mutate(
    founded_year_tertile = cut_number(founded, 3)
    ) %>% 
  group_by(founded_year_tertile) %>% 
  mutate(
    n_types_by_founded_year_tertile = cut_number(number.of.types, 3)
  ) %>% 
  ungroup()

table(breweries_wrangle$founded_year_tertile)
mv_tertile_1 = breweries_wrangle %>% 
  filter(founded_year_tertile== "[1.35e+03,1.77e+03]") %>% 
  mapview(
    col.regions = rainbow(3),
    zcol = "n_types_by_founded_year_tertile",
    layer.name = "n types by founded year tertile (oldest)")

mv_tertile_2 = breweries_wrangle %>% 
  filter(founded_year_tertile== "(1.77e+03,1.88e+03]") %>% 
  mapview(
    col.regions = rainbow(3),
    zcol = "n_types_by_founded_year_tertile",
    layer.name = "n types by founded year tertile (middle age)")

mv_tertile_3 = breweries_wrangle %>% 
  filter(founded_year_tertile== "(1.88e+03,2.01e+03]") %>% 
  mapview(
    col.regions = rainbow(3),
    zcol = "n_types_by_founded_year_tertile",
    layer.name = "n types by founded year tertile (youngest)")

mv_tertile_1+
mv_tertile_2+
mv_tertile_3

Screen Shot 2022-05-25 at 7 58 05 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant