Matplotlib and Matplotlib
Matplotlib may encounter color selection problems. Many people may think that the color of their own matlab style is not good. Fortunately, Matplotlib has foreseen this problem. In addition to supporting the most basic traditional matlab colors, it also supports many color Expressions:
RGB or RGBA floating point value tuples,[0, 1]
For example(0.1, 0.2, 0.5)
Or(0.1, 0.2, 0.5, 0.3)
.
RGB or RGBA hexadecimal string, such#0F0F0F
Or#0F0F0F0F
.
[0, 1]
A string representation of a floating point value, used to represent a gray scale, for example0.5
.
{'b', 'g', 'r', 'c', 'm', 'y', 'k', 'w'}
.
The color name of X11/CSS4.
One of the XKCD colors,'xkcd:'
Is the prefix, for example'xkcd:sky blue'
.
{'C0', 'C1', 'C2', 'C3', 'C4', 'C5', 'C6', 'C7', 'C8', 'C9'}
.
{'tab:blue', 'tab:orange', 'tab:green', 'tab:red', 'tab:purple', 'tab:brown', 'tab:pink', 'tab:gray', 'tab:olive', 'tab:cyan'}
. This is the Tableau color of the T10 palette (default color)
In this article, the color representation mentioned by the author is relatively simple. It is the X11 color description method mentioned above. All colors and Corresponding English names are listed in the X11 wiki:
In addition, the colors in matplotlib are case sensitive. The uppercase color names provided in wiki are not necessarily used directly, but must be written in lowercase.
Another way to use a ready-to-use color is to use the xkcd color mentioned above. You can find the color of the xkcd tag on this website. The source of xkcd color is also amazing. xkcd conducted a survey to investigate the user's names for various colors and finally obtained the xkcd color name. Therefore, the xkcd and X11 colors are many different. The same name may correspond to different colors. Matplotlib provides a comparison table to compare the naming differences between the two systems: