Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to realize functional drawing by Matplotlib

Shulou Source: shulou.com Published: 2022-06-01 18:37:33 10月01日 Update

This article will explain in detail how to achieve functional drawing in Matplotlib. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

A brief introduction to 0Jet Matplotlib

Matplotlib is the most famous library for data visualization in Python data analysis, and its drawing method is very similar to that in matlab.

There are usually two different ways to draw with Matplotlib: object-oriented drawing and functional drawing. In addition, you can also draw quickly with the plot function of dataframe. Their characteristics are as follows.

1. Object-oriented drawing Scheme (ax.plot) has clear structure, complete functions and easy to understand. [recommended]

2. The functional drawing scheme (plt.plot) code is relatively short, but it is easy to lose the operating object and cause confusion.

3Jing dataframe rapid drawing scheme (df.plot) can link up the data analysis and visualization process well. [highly recommended]

The functional drawing scheme is summarized as follows.

The functional drawing scheme is very similar to the style of matlab drawing.

When you complete a simple drawing task, the code is short.

When the drawing task is more complex, it is easy to get lost and need to switch to the object-oriented style.

First, functional drawing demonstration

Second, color, linetype and marking

1, control color

The correspondence between colors is

B---blue c---cyan g---green k----black

M---magenta r---red w---white y----yellow

There are four ways to represent colors

(1) use English full name or abbreviation such as: purple

(2) use hexadecimal such as # FF00FF

(3) use RGB or RGBA tuples.

(4) Grayscale intensity such as' 0.7'

(note, An in RGBA represents Alpha channel, which controls transparency.)

Several recommended drawing colors are: red, green and blue (rbg), c---cyan (cyan)

M---magenta (magenta). Set transparency if necessary.

2, control linetype

The corresponding relationship between symbols and linetypes is

-solid line

-- short term

-. Short point interphase line

Dotted line

3. Control tag style

On "Matplotlib how to achieve functional drawing" this article is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, please share it out for more people to see.

Tags: Drawings functions objects schemes methods colors controls data articles linetypes styles recommendations brevity between code tasks data analysis more markup transparency Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Linux MySQL macOS Shulou Information