Python matplotlib drawing Usage Guide! The cheats have been imparted to you!

Source: Internet
Author: User

Most people don't spend a lot of time learning the Matplotlib library, and still can implement the drawing needs, because there are already people on the open-source platform such as StackOverflow, GitHub to provide the majority of drawing problem solutions. We usually use Google to complete our drawing needs. At least that's what I am.

Matlibplot provides a variety of drawing UIs that can be categorized as follows:

    • Popup window and interactive interface:%matplotlib Qt and%matplot tk

    • Non-interactive inline drawing:%matplotlib inline

    • Interactive inline drawing:%matplotlib notebook--> Don't use this, it will make the switch difficult.

2. Understanding the Matplotlib object structure

Pyplot is a Matplotlib object-oriented function interface.

PLT.GCA ()

It returns the axis associated with the current plot ()

If you do not use Plt.close (), an empty graphic is displayed. Because the inline command was used at the beginning.

AXIS_ID is still the same, but when we move to another Notebook block, PLT.GCA () changes.

When we use axes[i], we can call any axes object in any previous code block, but calling Plt.bla () creates a new axes object in each code block and only calls the current object. Therefore, in the example above, the new Plt object is created only when Plt.title () is called.

Important observation: We usually call Plt.bla () on the current Axis object, which makes the axis objects in each code block newly created. But by calling Fig.axes[0], we can also process the previous axes object from any block of code.

From: https://matplotlib.org/faq/usage_faq.html

4. Basic examples of drawing

A basic example of how to draw, covering all aspects of object-oriented drawing. Please read it carefully.

Summarize the above example:

    • We create 1 rows and 2 columns of graphics. That is, 2 axes objects in 1 rows and 2 columns.

The idea is to consider the above graphic as a 2x4 grid. Then assign multiple grids to a single graph to accommodate the desired graphics.

Focus:

    • We can use Subplot2grid to customize our drawing layout.

    • We can use Plt.figure () to create a graphic with no axes object and then manually add the Axes object.

    • We can use Fig.suptitle () to set the overall caption of the entire graph.

7. Line style and line width

Change the line width, color, or style.

8. Basic Data distribution

The necessary operations in the EDA process.

9. Contour and color grid for two-D arrays

Thermal image (color grid) and contour plots help visualize 2D data in many cases.

10. Image adjustment, modification of edge coordinates and scale

Finally, adjust the details to make the drawing look better.

11. Scale limits and automatic adjustment

13. Axis

14. End

Blog site: Https://www.kaggle.com/grroverpr/matplotlib-plotting-guide/notebook

You are also welcome to pay attention to my blog or public number OH: Https://home.cnblogs.com/u/Python1234/Python Learning Communication

Welcome to my thousand-person conversation group: 125240963

Python matplotlib drawing Usage Guide! The cheats have been imparted to you!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.