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

Example Analysis of drawing function with python pyplot

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

Share

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

In this issue, the editor will bring you an example analysis of using python pyplot to draw functions. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.

Brief introduction

This paper mainly introduces how to draw function diagram through pyplot. The main drawing functions are as follows:-unary quadratic function-exponential function-natural logarithmic function-sine function

Unary first order function

Code

Import matplotlib.pyplot as pltimport numpy as npx = np.arange (0,10,0.1) y = x * 2plt.title ("unary linear function") plt.plot (x, y) plt.show ()

Unary quadratic function

Code

Import matplotlib.pyplot as pltimport numpy as npx = np.arange (- 10,10,0.1) y = X-ray 2 + 2x + 1plt.title ("quadratic function of one variable") plt.plot (x, y) plt.show ()

Exponential function

Code

Import matplotlib.pyplot as pltimport numpy as npimport mathx = np.arange (0,10,0.1) y = 2**xplt.title ("exponential function") plt.plot (x, y) plt.show ()

Natural logarithmic function

Code

Import matplotlib.pyplot as pltimport numpy as npimport mathx = np.arange (0,10,0.1) e = math.ey = e**xplt.title ("natural logarithmic function") plt.plot (x, y) plt.show ()

Sinusoidal function

Code

Import matplotlib.pyplot as pltimport numpy as np# linspace the first parameter sequence start value, the second parameter sequence end value, the third parameter is the sample number default 50x = np.linspace (- np.pi, np.pi, 100) y = np.sin (x) plt.title ("sine function") plt.plot (x, y) plt.show ()

The above is Xiaobian for you to share the use of python pyplot drawing function analysis of the example, if there happens to be a similar doubt, you might as well refer to the above analysis to understand. If you want to know more about it, 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: 208

*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