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 matplotlib drawing to establish canvas and coordinate system in Python

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

Share

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

Editor to share with you how to use matplotlib drawing in Python to establish canvas and coordinate system, I believe most people do not know much about it, so share this article for your reference. I hope you will get a lot after reading this article. Let's learn about it together.

First, set up the canvas

Import matplotlib.pyplot as pltimport numpy as npx=np.arange (8) y=np.arange (8) print (XMagney) # establishes canvas figsize, which uses width and height to control the width and height of canvas plt.figure (figsize= (8) 6), dpi=90) # facecolor='red' sets canvas color 2, uses plt.subplot function to establish coordinate system, and draws line chart and bar chart respectively

Plt.subplot (2) 2) # means to divide the whole area of the icon into 2 rows and 2 columns in the first coordinate system to draw plt.plot (x ~ 2) plt.subplot (2 ~ 2 ~ 2) # draw plt.bar (x ~ y) plt.subplot (2 ~ 2 ~ 2 ~ 3) in the second coordinate system # draw plt.plot (x ~ y) plt.subplot (2 ~ 2 ~ 2 ~ 4) in the third coordinate system # draw plt.bar (x ~ (x) in the fourth coordinate system. Y) the complete code is as follows

Import matplotlib.pyplot as pltimport numpy as npx=np.arange (8) y=np.arange (8) print (XMago y) # establishes canvas figsize, which uses width and height to control the width and height of the canvas plt.figure (figsize= (8jue 6), dpi=90) # facecolor='red' sets the canvas color plt.subplot (2pr 2) # means to divide the entire area of the icon into 2 rows and columns to draw plt.plot (x reference y) plt.subplot (2p2) in the first coordinate system 2) # in the second coordinate system, draw plt.bar (XMague y) plt.subplot (2Power2 Magne3) # draw plt.plot (XMague y) plt.subplot in the third coordinate system (2Power2 Magne4) # draw plt.bar (XMagol y) plt.show () 4 in the fourth coordinate system. The corresponding effect figure is shown below.

The above is all the content of the article "how to use matplotlib drawing to build canvas and coordinate system in Python". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, 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