Search icon
Subscription
0
Cart icon
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Matplotlib 2.x By Example

You're reading from  Matplotlib 2.x By Example

Product type Book
Published in Aug 2017
Publisher Packt
ISBN-13 9781788295260
Pages 334 pages
Edition 1st Edition
Languages
Authors (3):
Allen Yu Allen Yu
Profile icon Allen Yu
Claire Chung Claire Chung
Profile icon Claire Chung
Aldrin Yim Aldrin Yim
Profile icon Aldrin Yim
View More author details

Title and legend


Title and legend are pieces of text that facilitate quick comprehension of the data context. Although a title is not required or recommended, sometimes, such as in inline figures of many scientific publications, adding a title for your plot often helps make the message clear, especially when your figure is not accompanied by explanatory text. For plots with multiple datasets, it is a good practice to keep a data legend with a distinct color or pattern code labeled with the corresponding identities.

Adding a title to your figure

The title of a figure can be set by pyplot.title() or axes.set_title(). Text properties can be supplied as keyword arguments.

Adding a legend

Adding a legend of data labels in Matplotlib is as simple as setting label='yourlabel' when plotting and adding pyplot.legend() before pyplot.show(). By default, Matplotlib finds the "best" location to prevent the legend from overlapping with data. You may also specify a location using pyplot.legend(loc='3', **kwargs...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}