1. Finalizing the plot for different audiences and devices
You're almost done! In this last section of the second chapter, you're going to finalize your dot plot, apply your custom theme and make it fit for different audiences and devices.
2. <<<New Slide>>>
Let's have a look at the current state of your plot. The labels are now shifted so they don't overlap with the arrows anymore, and they already have the right font family, color and size. They will look great together with your custom theme you are going to apply shortly. However, you've introduced another problem. The labels now overlap with the plot panel borders on the left and right side of the panel. In the following exercise, you are going to change the viewport in order to solve this problem.
3. coord_cartesian vs. xlim / ylim
There are basically two ways you can change the viewport of your plot - that is, to zoom in or out, or to change the position of the viewport. On one hand there's the possibility of adding xlim and ylim arguments to the coord_cartesian function, which is the default coordinate system for ggplot objects. Here, we set the x dimension to go from 0 to 100 and the y dimension to go from 10 to 20, even though our data might not span this range.
Then there's also the possibility to directly call the xlim and ylim functions and add them to the ggplot_object. Does this give the same results?
4. coord_cartesian vs. xlim / ylim
Almost! The difference is subtle but important. Using coord_cartesian retains all data points in the plot, while using xlim or ylim actually clips the data and removes points outside of the viewport. This may result in ugly artifacts. So, I would argue it's generally better to use coord_cartesian.
5. <<<New Slide>>>
After this last correction, you will apply your previously defined theme. That's how the plot will look after this.
It contains everything a good plot needs: A descriptive title, axes titles and labels as well as the data source. People who look at the plot will immediately understand what it is about, and the ordering of the items makes comparing countries easy. Also, the plot looks not like a normal ggplot, rather it's customized and especially aesthetic thanks to your own theme.
6. Desktop vs. Mobile audiences
However, there's still a problem. While your plot works great on Desktop monitors, looking at it on a mobile device is painful.
See? That's how it would look. The fonts are way too small and only a small fraction of the screen is filled out. People would have to turn their phone to see the plot in the right aspect ratio. If they don't do that – and don't ever expect it – they have to tediously zoom in and out and pan around to grasp the big picture of the plot.
Here's an alternative proposal. The plot now has a 16:9 portrait aspect ratio, which fits most smartphone screens nicely. You may not see it on the slides, but the font size is bigger and thus more readable. Also: The axes are completely missing, and the country labels have been shifted to the inside of the plot, right under the arrows. This way, we can save the space the axes take. Actually, after shifting the country labels to the data items, they were superfluous anyway, because the weekly working hours for both years were already shown in the plot, too.
In the following exercises, you will not only finalize the desktop version of your plot, but also customize it so it works better on mobile devices and thus on social media.
7. Let's produce these plots!
Let's do this!