Search icon CANCEL
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

Setting colors in Matplotlib


Many elements in a Matplotlib figure can have their colors specified. There are several ways to do so. You will come across the color parameter as a keyword argument for style settings very often in different functions. The alternate abbreviated keyword c can often be used. We will first briefly introduce the general rule here.

Single letters for basic built-in colors

There is a list of common colors we can quickly call with single letters:

  • b: Blue
  • g: Green
  • r: Red
  • c: Cyan
  • m: Magenta
  • y: Yellow
  • k: Black
  • w: White

Names of standard HTML colors

Examples are coralgoldspringgreendeepskyblue, and blueviolet. You can find the full list here: https://matplotlib.org/examples/color/named_colors.html.

RGB or RGBA color code

You can parse a tuple of three to four float numbers in the range of 0-1, such as (0.2,0.4,0.8) or (0.2,0.2,0.3,0.8). The first three numbers are RGB values that define the amount of red, green, and blue light to mix in the color. The optional fourth number is...

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 €14.99/month. Cancel anytime}