Unit 43Mastering Embellishments

With pyplot, you can control a lot of aspects of plotting.

You can set and change axes scales ("linear" vs. "log"—logarithmic) with the xscale(scale) and yscale(scale) functions, and you can set and change axes limits with the xlim(xmin, xmax) and ylim(ymin, ymax) functions.

You can set and change font, graph, and background colors, and font and point sizes and styles.

You can also add notes with annotate, arrows with arrow, and a legend block with legend. In general, refer to the pyplot documentation for the complete list of embellishment functions and their arguments, but let’s at least add some arrows, notes, and a legend to an already familiar NIAAA graph:

 import​ matplotlib, matplotlib.pyplot ...

Get Data Science Essentials in Python 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.