Issue Overview
Unable to reproduce same result. Legend is not ordered as video.
Describe your environment
platform aarch64-apple-darwin20
arch aarch64
os darwin20
system aarch64, darwin20
status
major 4
minor 2.2
year 2022
month 10
day 31
svn rev 83211
language R
version.string R version 4.2.2 (2022-10-31)
nickname Innocent and Trusting
Steps to Reproduce
library(tidyverse)
library(sf)
library(janitor)
library(rmapshaper)
library(tigris)
most_popular_pets <- read_csv("data/pet-searches-by-state.csv") %>%
clean_names()
order_pet_popularity <- most_popular_pets %>%
count(pet, sort = TRUE) %>%
pull(pet)
us_contiguous <- states() %>%
clean_names() %>%
mutate(statefp = as.numeric(statefp)) %>%
filter(statefp < 60,
!statefp %in% c(2, 15)) %>%
ms_simplify()
us_most_popular_pets <- us_contiguous %>%
left_join(most_popular_pets,
by = c("name" = "state"))
colors_pets <-
list(
"Hamster" = "#AE76A6",
"Guinea pig" = "#92BFB1",
"Chinchilla" = "#694A38",
"Sugar glider" = "#A61C3C",
"Bearded dragon" = "#FFAD05"
)
colors_pets <- colors_pets[order_pet_popularity]
us_most_popular_pets <- us_most_popular_pets %>%
filter(!is.na(pet))
ggplot() +
geom_sf(data = us_most_popular_pets,
aes(fill = pet),
color = "white",
size = 0.2) +
scale_fill_manual(values = colors_pets,
name = "Most popular pet") +
theme_void()
Expected Behavior
I expect legend to be ordered by most popular pet as per video. Nope. I loaded 04_03e and got same result.
Current Behavior
colors_pets is ordered but scale_fill_manual is not displaying legend as per ordered colors
Possible Solution
Screenshots / Video

Related Issues
Issue Overview
Unable to reproduce same result. Legend is not ordered as video.
Describe your environment
platform aarch64-apple-darwin20
arch aarch64
os darwin20
system aarch64, darwin20
status
major 4
minor 2.2
year 2022
month 10
day 31
svn rev 83211
language R
version.string R version 4.2.2 (2022-10-31)
nickname Innocent and Trusting
Steps to Reproduce
library(tidyverse)
library(sf)
library(janitor)
library(rmapshaper)
library(tigris)
most_popular_pets <- read_csv("data/pet-searches-by-state.csv") %>%
clean_names()
order_pet_popularity <- most_popular_pets %>%
count(pet, sort = TRUE) %>%
pull(pet)
us_contiguous <- states() %>%
clean_names() %>%
mutate(statefp = as.numeric(statefp)) %>%
filter(statefp < 60,
!statefp %in% c(2, 15)) %>%
ms_simplify()
us_most_popular_pets <- us_contiguous %>%
left_join(most_popular_pets,
by = c("name" = "state"))
colors_pets <-
list(
"Hamster" = "#AE76A6",
"Guinea pig" = "#92BFB1",
"Chinchilla" = "#694A38",
"Sugar glider" = "#A61C3C",
"Bearded dragon" = "#FFAD05"
)
colors_pets <- colors_pets[order_pet_popularity]
us_most_popular_pets <- us_most_popular_pets %>%
filter(!is.na(pet))
ggplot() +
geom_sf(data = us_most_popular_pets,
aes(fill = pet),
color = "white",
size = 0.2) +
scale_fill_manual(values = colors_pets,
name = "Most popular pet") +
theme_void()
Expected Behavior
I expect legend to be ordered by most popular pet as per video. Nope. I loaded 04_03e and got same result.
Current Behavior
colors_pets is ordered but scale_fill_manual is not displaying legend as per ordered colors
Possible Solution
Screenshots / Video
Related Issues