In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail how to install and use matplotlib for everyone. Xiaobian thinks it is quite practical, so share it with you for reference. I hope you can gain something after reading this article.
1. Matplotlib Profile
Matplotlib is a Python 2D drawing library that generates publication quality data in a variety of hardcopy formats and cross-platform interactive environments. Matplotlib is available for Python scripts, Python and IPython shells, Jupyter notebooks, Web application servers and four graphical user interface toolkits.
2. matplotlib installation
Matplotlib installation can be done using source installation and pip installation. Pip is installed as follows:
pip install matplotlib
The latest version is installed by default, or a specified version can be installed
pip install matplotlib==2.2.03. matplotlib Plot Example 3.1 Compiling Common Statistics Graphs
scatter plot
x = np.arange(50)y = x + 5 * np.random.rand(50)plt.scatter(x, y)plt.title ('scatter plot ') #Add title plt.xlabel ('argument ') #Add abscissa plt.ylabel ('dependent variable') #Add ordinate plt.xlim(xmin=0, xmax=50) #Add abscissa range plt.ylim(ymin=0, ymax=50) #Add ordinate range
histogram
plt.hist(x=np.random.randn(100), bins=10, color='b', alpha=0.3)
line chart
plt.plot([1,2,3,4,5],[1,4,5,2,7])
histogram
x = np.arange(5)y1, y2 = np.random.randint(1, 25, size=(2, 5))width = 0.25plt.bar(x, y1, width, color='r')plt.bar(x+width, y2, width, color='g')
pie chart
explode=(0,0.1,0,0,0)partions = [0.30,0.20,0.1,0.15,0.25]labels =<$'Apple ',' Samsung','Millet',' Huaweis','others'] plt.pie(partions,labels=labels,explode=explode,autopct='%1.0f%%')
3.2 Converting mathematical function curves
trigonometric function
x = np.arange(-np.pi,np.pi,0.01)y1 = np.sin(x)y2 = np.cos(x)plt.plot(x,y1,color='green', linewidth=1,linestyle='-',label=' sinusoidal') plt.plot(x,y2,color='blue', linewidth=1,linestyle='--',label=' cosine curve') plt.legend() #Add labels
exponential function
t = np.linspace(-50.0,50.0,1000)func_exp = np.exp(-0.1*t)plt.plot(t,func_exp)plt.title('exp(-0.1*t)')
logarithmic function
t = np.linspace(-10.0,10.0,1000)func_log2 = np.log2(t)plt.plot(t,func_log2)plt.title('log2(t)')plt.grid()
About "matplotlib how to install and use" this article is shared here, I hope the above content can be of some help to everyone, so that you can learn more knowledge, if you think the article is good, please share it 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.