In addition to Weibo, there is also WeChat
Please pay attention

WeChat public account
Shulou
2025-11-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to draw a line between two points in matplotlib. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
In order to find the method of connecting matplotlib between two points, this paper mainly introduces several methods of drawing the line between two points by matplotlib, as follows
Drawing method this article will disassemble several components of Matplotlib drawing through the simplest mode, and cover the following
1. Create a dataset
2. Create a canvas
3. Add data to canvas
4. Show the figureimport numpy as npimport matplotlib.pyplot as plt # create a datasetpoints = np.linspace (- 5,5,256) y1 = np.tanh (points) + 0.5y2 = np.sin (points)-0.2 # create a canvasfig, axe = plt.subplots (figsize= (7,3.5), dpi=300) # add data to canvas axe.plot (points, y1) axe.plot (points, y2) # show the figurefig.savefig ('output/to.png') plt.close (fig)
The drawing method uses pyplot to draw the image import matplotlib.pyplot as pltimport numpy as np x = np.linspace (- 3,3256) y = np.sin (x) plt.plot (x, y)
The drawing method uses the axes class to draw images
Use axes to draw a single image using subplot () and subplots (nrows,ncols) to draw multiple graphics
Import matplotlib.pyplot as pltimport numpy as np x = np.linspace (- 3,3256) y = np.sin (x) ax = plt.subplot () ax.plot (x, y)
The drawing method uses the figure class to draw the image import matplotlib.pyplot as pltimport numpy as np x = np.linspace (- 3,3256) y = np.sin (x) fig = plt.figure (dpi=300) ax = fig.add_subplot (111ax.plot (x, y) fig.savefig ('output/to.png') plt.close (fig))
Represents the position of the image. If you use subplots, there are nrows, ncols, and index three parameters, of which idex starts from 1, on behalf of the upper left corner of the image on "matplotlib how to draw a connection between two points" 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.
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.

The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope





About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.