Changing the base of the log scale

While a log base of 10 is common, we might need to use other bases when the data has a larger or smaller range. The base of the log scale can be adjusted by using the two keyword arguments, basex or basey, in pyplot.xscale() and pyplot.yscale() respectively. In the following example, a log2 scale is used on the y axis. 

This time, we add basey=2 in our pyplot.yscale() call:

plt.yscale('log', basey=2)

Get Matplotlib 2.x By Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.