This is my data:
df <- data.frame(
city = c("Chicago", "Chicago", "Denver", "Denver", "Los Angeles", "Los Angeles", "Minneapolis", "Minneapolis",
"New York", "New York", "Philadelphia", "Philadelphia", "Portland", "Portland", "San Francisco", "San Francisco",
"Seattle", "Seattle", "Uppsala", "Uppsala", "Washington", "Washington"),
state = c("Illinois", "Illinois", "Colorado", "Colorado", "California", "California", "Minnesota", "Minnesota",
"New York", "New York", "Pennsylvania", "Pennsylvania", "Oregon", "Oregon", "California", "California",
"Washington", "Washington", "Sweden", "Sweden", "District of Columbia", "District of Columbia"),
percent = c(1.3, 1.3, 2.3, 2.3, 1.0, 1.0, 4.1, 4.1, 0.8, 0.8, 2.0, 2.0, 6.1, 6.1, 3.4, 3.4, 3.4, 3.4, 29.0, 29.0, 3.1, 3.1),
workers = c(1206615, 1206615, 305174, 305174, 1724400, 1724400, 203268, 203268, 3557250, 3557250, 587750, 587750,
300246, 300246, 436265, 436265, 352059, 352059, 83737, 83737, 301516, 301516),
bikers_sort = c(15686, 15686, 7019, 7019, 17244, 17244, 8334, 8334, 28458, 28458, 11755, 11755,
18315, 18315, 14833, 14833, 11970, 11970, 24284, 24284, 9347, 9347),
non_bikers = c(1190929, 1190929, 298155, 298155, 1707156, 1707156, 194934, 194934, 3528792, 3528792, 575995, 575995,
281931, 281931, 421432, 421432, 340089, 340089, 59453, 59453, 292169, 292169),
type = c("bikers", "non_bikers_clipped", "bikers", "non_bikers_clipped", "bikers", "non_bikers_clipped", "bikers",
"non_bikers_clipped", "bikers", "non_bikers_clipped", "bikers", "non_bikers_clipped", "bikers", "non_bikers_clipped",
"bikers", "non_bikers_clipped", "bikers", "non_bikers_clipped", "bikers", "non_bikers_clipped", "bikers", "non_bikers_clipped"),
n = c(15.686, 485.314, 7.019, 298.155, 17.244, 483.756, 8.334, 194.934, 28.458, 472.542, 11.755, 489.245, 18.315,
281.931, 14.833, 421.432, 11.970, 340.089, 24.284, 59.453, 9.347, 292.169)
)
How can I remove these spaces marked in black in my image? Basically, I need to remove the top and bottom spaces of my ggplot.
Any help?
This is my code:
ggplot(df, aes(fill = type, values = n)) +
geom_waffle(size = .25, n_rows = 10,flip = T, color = 'lightgray')+
scale_fill_manual(name = "Countries",
values = c(main_color, second_color),
labels = c("China", "USA"))+
facet_wrap(facets = ~fct_reorder(city, bikers_sort, .desc = TRUE), nrow = 1, strip.position = "bottom",
)+
coord_equal()