In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "what is matplotlib in python", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "what is matplotlib in python" this article.
What is matplotlib?
Partners who have used python for data analysis know that matplotlib is a commanding, low-level, customizable, rich in chart resources, easy to use, publishing quality level of python 2D drawing library.
Matplotlib is the veteran library of python drawing, similar to the C language in the programming language. Many other python drawing libraries are developed based on matplotlib, such as seaborn, ggplot, plotnine, holoviews, basemap and so on.
Matplotlib can be used for python scripts, python shell, jupyter notebook, web, and so on. The best tool to run matplotlib drawings is jupyter notebook, and this tutorial is also based on this tool for experiments. This is an interactive notebook that runs code on a browser and can directly display the results and charts, as described in jupyter notebook.
Which charts can be drawn with matplotlib?
Histogram, dotted chart, histogram, pie chart, stacked histogram, filling histogram, histogram, area chart, trend chart, box chart, violin chart, data map, radar chart, funnel chart, nested pie chart, all kinds of 3D charts, etc., and so on.
Some of the drawings are listed. For details, please see: matplotlib gallery
The use of matplotlib drawing mainly uses its pyplot module, which can be programmed to generate a variety of charts, as long as a simple function can customize the chart independently, adding text, points, lines, colors, images and other elements.
What are the adjustable chart elements?
These elements need to be controlled by methods in the pyplot module, which will be described one by one in future examples.
How do I install matplotlib?
Matplotlib and its dependent packages can be installed through pip, which is very simple. On the command line, enter:
Pip install matplotlib
For beginners, they are tired of installing various packages. You can download and install Anaconda directly, including python and hundreds of data science third-party libraries, once and for all.
How to use matplotlib drawing?
1. Open jupyter notebook and create a new python3 notebook with the following interface:
2. Import the pyplot module and use the magic image function to display the chart in notebook
Import matplotlib.pyplot as plt
% matplotlib inline # magic function
3. Type the drawing code
Plt.figure () # create a figure object
Plt.plot ([1,2,3,4], [1,2,3,4], label='my first line') # drawing function plot
Plt.legend () # legend function, which is used to adjust the position of the legend, etc.
Plt.xlabel ('X') # x axis label
Plt.ylabel ('Y') # y axis label
Plt.show () # display chart
4. Results
What do the pyplot module method functions do here?
Plot (): draw a straight line or mark according to the given x and y values
Figure (): create a new chart
Legend (): place a legend on a chart
Xlabel (): label the x-axis
Ylabel (): label the y-axis
Show (): show chart
The above is all the content of this article "what is matplotlib 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.
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.