Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use subplot and subplots of Matplotlib

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the Matplotlib subplot and subplots how to use the relevant knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe you will have something to gain after reading this Matplotlib subplot and subplots article, let's take a look at it.

The comparison begins:

Requirements: draw two subgraphs and display them on one line. The contents of the subgraphs are exactly the same.

Subplot Code:

Ax1 = plt.subplot ax1.scatter (positive ['X1'], positive [' X2'], sword50, marker='x', label='Positive') ax1.scatter (negative ['X1'], negative [' X2'], scurvie 50, marker='o', label='Negative') ax1.legend () # adding the image column is the top right-hand corner, indicating that ax2 = plt.subplot (1mezzo 2) ax2.scatter (positive ['X1'], positive [' X2'], slot50, marker='x') Label='Positive') ax2.scatter (negative ['X1'], negative [' X2'], saw50, marker='o', label='Negative') ax2.legend () # add the column is the point description in the upper right corner

Subplots Code:

Fig, ax = plt.subplots (figsize= (12Power8), ncols=2,nrows=1) # this method returns the drawing object and coordinate object ax,figsize is to set the length and width of the subimage (1200 Ax [0] .audter (positive ['X1'], positive [' X2'], sprinter 50, marker='x', label='Positive') ax [0] .accounter (negative ['X1'], negative [' X2'], slot50, marker='o', label='Negative') ax [0] .explanation () # adding the image column is the dot description in the upper right corner ax [1] .roomter (positive ['X1'], positive [' X2'], sprinter 50, marker='x' Label='Positive') ax [1] .roomter (negative ['X1'], negative [' X2'], saw50, marker='o', label='Negative') ax [1] .adding the figure column is the comparison result in the upper right corner:

You can see that both of them can achieve the function of drawing sub-images, but subplots helps us plan the artboard and returns an array of coordinate objects, while subplot can only return one coordinate object at a time. Subplots can directly specify the size of the artboard.

This is the end of the article on "how to use Matplotlib's subplot and subplots". Thank you for reading! I believe you all have a certain understanding of the knowledge of "how to use Matplotlib's subplot and subplots". If you want to learn more, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report