We have just learned how to turn numerical values into dots and lines with Matplotlib. By default, Matplotlib optimizes the display by calculating various values in the background, such as the reasonable axis range and font sizes. However, good visualization often requires more design input to suit our custom data visualization needs and purpose. Moreover, text labels are needed to make figures informative in many cases. In the following sections, we will demonstrate the methods to adjust these elements.
While Matplotlib automatically chooses the range of x and y axis limits to spread data onto the whole plotting area, sometimes we want some adjustment, such as to show 100% as maximum instead of somewhere lower. To set the limits of x and y axes, we use the commands plt.xlim()
and plt.ylim()
. In our daily temperature example, the auto-scaling makes the temperature changes of less than 2 degrees Celsius seem very dramatic...