July 2019
Beginner to intermediate
740 pages
16h 52m
English
Back in Chapter 1, Introduction to Data Analysis, we discussed how our axis limits can make for misleading plots if we aren't careful. With matplotlib, we can adjust the limits of each axis with plt.xlim() and plt.ylim(). We pass values for the minimum and maximum, separately; if we want to keep what was automatically generated, we can pass None. Let's plot Facebook stock's closing price and start the y-axis at zero:
>>> fb.open.plot(figsize=(10, 3), title='FB opening price 2018')>>> plt.ylim(0, None)>>> plt.ylabel('price ($)')
Notice that the y-axis now begins at zero:

Read now
Unlock full access