Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 31 additions & 10 deletions examples/color/named_colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@
List of named colors
====================

This plots a list of the named colors supported in matplotlib. Note that
:ref:`xkcd colors <xkcd-colors>` are supported as well, but are not listed here
for brevity.

This plots a list of the named colors supported in matplotlib.
For more information on colors in matplotlib see

* the :doc:`/tutorials/colors/colors` tutorial;
* the `matplotlib.colors` API;
* the :doc:`/gallery/color/color_demo`.

----------------------------
Helper Function for Plotting
----------------------------
First we define a helper function for making a table of colors, then we use it
on some common color categories.
"""

from matplotlib.patches import Rectangle
Expand Down Expand Up @@ -73,22 +76,40 @@ def plot_colortable(colors, title, sort_colors=True, emptycols=0):

return fig

#############################################################################
# -----------
# Base colors
# -----------

plot_colortable(mcolors.BASE_COLORS, "Base Colors",
sort_colors=False, emptycols=1)

#############################################################################
# ---------------
# Tableau Palette
# ---------------

plot_colortable(mcolors.TABLEAU_COLORS, "Tableau Palette",
sort_colors=False, emptycols=2)

#############################################################################
# ----------
# CSS Colors
# ----------

# sphinx_gallery_thumbnail_number = 3
plot_colortable(mcolors.CSS4_COLORS, "CSS Colors")

# Optionally plot the XKCD colors (Caution: will produce large figure)
# xkcd_fig = plot_colortable(mcolors.XKCD_COLORS, "XKCD Colors")
# xkcd_fig.savefig("XKCD_Colors.png")

plt.show()


#############################################################################
# -----------
# XKCD Colors
# -----------
# XKCD colors are supported, but they produce a large figure, so we skip them
# for now. You can use the following code if desired::
#
# xkcd_fig = plot_colortable(mcolors.XKCD_COLORS, "XKCD Colors")
# xkcd_fig.savefig("XKCD_Colors.png")
#
# .. admonition:: References
#
Expand Down