I had started a "Vis" initiative back on encourage folks to get practice making visualizations since that ' s the The only-to-get better at virtually anything. Life got crazy, Vis fell to the wayside and now there is more visible alternatives such as makeover Mondayand Workout Wednesday. They ' re geared towards the "T" crowd (I ' m not giving a closed source and locked-in-data product no more marketing than TW O links) But this doesn ' t mean R, Python or other open-tool/open-data communities can ' t join on for the ride and learning Experience.
This week ' s workout are a challenge to reproduce or improve upon a chart by Matt Stiles. You should go to both (give them the clicks and eyeballs they both deserve since they do great work). They both chose a line chart, and the whole point of these exercises are to try out new things to help you learn what to COM Municate better. I chose to geom_segment()
Mini-column charts since that:
- Eliminates the giant rose-coloured rectangles that end up everywhere
- Helps show the differences a bit better (IMO), and
- Also helps highlight some of the states that has had more difficulties than others
Click/tap to "Embiggen". I kept the same dimensions that Andy do but unlike Matt's creation this was a plain ol ' PNG as I didn ' t want to deal with Web fonts (I ' m on a Museo Sans condensed kick at the moment, but don ' t has it in my TypeKit config yet). I went with official annual unemployment numbers as they could be calculated/adjusted differently (i-didn ' t check, but I Kne W that data source existed, so I used it).
One reason I ' m doing this was a quote on the Workout Wednesday post:
This would be a very tedious exercise. To provide some context, this took me 2-3 hours to create. Don ' t get discouraged and don ' t feel like you had to do it all in one sitting. Basically, try to make yours look identical to mine.
This took me minutesto the Create in R:
#‘ ---# ' Output:# ' Html_document:# ' Keep_md:true#‘ ---#+ message=falselibrary(Ggplot2) Library(Hrbrmisc) Library(READXL) Library(Tidyverse)# Use official BLS Annual unemployment data vs manually calculating the average# Source:https://data.bls.gov/timeseries/lnu04000000?years_option=all_years&periods_option=specific_periods &periods=annual+dataread_excel("~/data/annual.xlsx", Skip=10)%>% Mutate(Year=as.character(As.integer(Year)), Annual=annual/100)Annual_rate# The data source Andy Kriebel curated for YOU/US:HTTPS://1DRV.MS/X/S!AHZVJTXF2-TD1UVEK7GYN2VN5HXN #ty Andy!read_excel("~/data/staadata.xlsx")%>% Left_join(annual_rate)%>% Filter(state!="District of Columbia")%>% Mutate(Year= As. Date(sprintf("%s-01-01", year)), the PCT=(Unemployed/' civilian Labor Force Population '), Us_diff=-(Annual-pct), col= IfElse(Us_diff<0,"Better than U.S. national Average","Worse than U.S. national Average"))Dfcredits<-"Notes:excludes the District of Columbia. Figure represents October Rate.\ndata:u.s. Bureau of Labor Statistics #+ State_of_us, fig.height=21.5, fig.width=8.75, Fig.retina=2ggplot(DFAes(Year, Us_diff, group=state))+ geom_segment(AES(xend=year, Yend=0, color=col), size=0.5)+ scale_x_date(Expand=c(0,0), Date_labels="'%y")+ scale_y_continuous(Expand=c(0,0), the label=scales::p ercent, limit=c(-0.09,0.09))+ scale_color_manual(Name=Null, expand=c(0,0), values=c(' Better than U.S. national Average '="#4575b4 ", ' Worse than U.S. national Average '="#d73027 ") + Facet_wrap(~state, Ncol=5, Scales="Free_x")+ Labs(x=NullY=Null, title="The state of U.S. jobs:1976-2016", subtitle="Percentage points below or above the national unemployment rate, by state. Negative values represent unemployment rates\nthat were lower-or better, from a jobs Perspective-than the national rat E. ", caption=credits)+ Theme_hrbrmstr_msc(Grid=Y, strip_text_size=9)+ Theme(Panel.background=element_rect(Color=" #00000000 ", fill=" #f0f0f055 ")) + Theme (Panel.spacing=unit (0.5" lines ") ) + theme (Plot.subtitle =element_text (Family= " MuseoSansCond-300 "" + Theme (Legend.position= "top" )
Swap out for ~/Data
where you stored the files.
The "weird" looking comments enable me to spin the script and are pretty much just the inverse markup for knitr
R Markdown Documents. As the comments say, you should really thank Andy for curating the BLS data for you/us.
If I really didn ' t pine over aesthetics it would has taken me 5 minutes (most of that is waiting for re-rendering). Formatting the blog post took much longer. Plus, I can update the data source and re-run this on the future without clicking anything. This re-emphasizes a caution I tell my students: beware of dragon droppings ("Drag-and-drop data Science/visualiz ation Tools ").
Hopefully you presently follow or would start following Workout Wednesday and makeover Monday and dedicate some time to hon E Your skills with those visualization katas.
Transferred from: https://rud.is/b/2017/01/18/workout-wednesday-redux-2017-week-3/
Workout Wednesday Redux (Week 3)