April 2018
Beginner to intermediate
300 pages
7h 34m
English
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. Here is how we can adjust it, say, to show 0 degrees as the lower limit on the y axis for temperatures of the first 5 days only:
import matplotlib.pyplot as pltd = [11,12,13,14,15,16,17]t0 = [15.3,12.6,12.7,13.2,12.3,11.4,12.8]t1 = [26.1,26.2,24.3,25.1,26.7,27.8,26.9]t2 = [22.3,20.6,19.8,21.6,21.3,19.4,21.4] ...Read now
Unlock full access