psrc / psrcplot

Package for Creating PSRC consistent data visualizations with R
https://psrc.github.io/psrcplot/
GNU General Public License v3.0
2 stars 0 forks source link

Update vignette re: wrapping x-axis labels #69

Closed MrichardsPSRC closed 1 year ago

MrichardsPSRC commented 1 year ago

https://psrc.github.io/psrcplot/articles/frequently-asked-questions.html#how-can-i-wrap-the-text-on-a-column-chart-x-axis--its-looking-messy

I think that the first screenshots under this section is incorrect since it's already fixed with wrapping? image

When it should look more like this: image

When I incorporate the text wrapping code, like provided in the example, it works well but the text is oriented horizontally (left-right), not like the text in the example screenshot which is oriented veritcally (bottom-top): image

# generate static column chart
xlabs <- levels(dt_2021_simprace$HRACE) %>% stringr::str_wrap(12)

own_race_chart <- static_column_chart(t=dt_2021_simprace, 
                                   x="HRACE", y="HINCP_median", 
                                   fill="HRACE",
                                   pos="dodge",
                                   est="currency",
                                   # moe="HINCP_median_moe",
                                   # href="ref_val", hrefnm="Region",
                                   # hrefcl='#00716c',
                                   title="Regional Household Median Income by Race and Hispanic/Latinx Origin",
                                   subtitle=NULL, 
                                   source="2021 American Commmunity Survey 1-year data",
                                   alt=NULL,
                                   xlabel=NULL, ylabel=NULL,
                                   dec = 0, color="psrc_light") + theme(legend.position = "none") +
  ggplot2::scale_x_discrete(labels=xlabs) #+ scale_x_discrete(limits=rev) #alphabetical order

image

I'm not sure if the screenshot should be updated or if I am missing something? Also not sure if it would be beneficial to include a note on how to orient the text vertically or horizontally? Based on my output it seems that the default it horizontal.

jensenmj commented 1 year ago

Solved with commit #e224253.