Open MrichardsPSRC opened 1 year ago
We can wrap the text by specifying the length,
c <- c + ggplot2::scale_color_discrete(labels = function(x) stringr::str_wrap(x, width = 15))
The trick here is to know how long and under what circumstances.
Taking a step back, though, I'd suggest more charts without legends at all: axis labels or even annotations within the chart are better for intuitive storytelling with data. If legend entries require wrapping, it busies things and makes quick association with the color harder. Everyone is mentally reducing that 48-character label to something shorter anyway; why not edit it down?
own_race_income_chart <- static_bar_chart(t=dt_2021_simprace, x="share", y="income_cat", fill="HRACE", pos="dodge", est="percent",
moe="share_moe",
This could be because I set the Rmarkdown to include Christy's suggested setting : {r own-race-income-chart, fig.width=10}
When I generate it in Rstudio: