In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly shows you the "what are the common commands for Python drawing", the content is simple and clear, and I hope it can help you solve your doubts. Let the editor lead you to study and learn what are the common commands for Python drawing.
Matplotlib library defaults to English fonts
Add bold ('SimHei') to the drawing font
Code:
Plt.rcParams ['font.sans-serif'] = [' SimHei'] 1. Simple routine bar chart
Basic method: matplotlib.pyplot.bar ()
Basic parameters: bar (xQuery y)
Other parameters: color color width width transparency alpha
Other methods: legend legend () horizontal axis definition xlable () vertical axis definition ylable () graph title title () scale method xlim (), ylim ()
Import matplotlib.pyplot as plt # drawing import pandas as pd # read exal file plt.rcParams ['font.sans-serif'] = [' SimHei'] # add boldface as drawing font name = ['tom',' rose', 'lucy'] # variable name installs a list weight = [60, 70, 80] # with location attributes and numerical attributes plt.bar (name, weight, label=' weight', color='green', alpha=0.5 Width=0.5) # call method + legend + color + transparency + width plt.xlabel ('name') plt.ylabel ('weight unit kg') plt.title (' three people's weight xx') plt.legend () plt.savefig ('bar chart .png', dip=500) plt.show () # display method
two。 Read exal method 2.1Common data processing Library: pandas
A common way to read excel files with pandas: the read_excel () parameter is the file name
Import matplotlib.pyplot as plt # drawing import pandas as pd # read the exal file Data = pd.read_excel ('E:\ PythonData/LandingData.xlsx') print (Data)
Note that the file path does not start with a number, or an error will be reported.
E:\ PythonData/LandingData.xlsx
2.2 extract list array 3. The type and format of the picture of the paper
Bitmap (mosaic after magnification): .jpg .tif .psd .bmp .png
Vector graphics (magnified and clear): .wmf .emf .epd .cdx
Things photography uses bitmaps
The .png format is a non-extensible file type; .pdf is an extensible file format, and pdf is a vector graph.
4. Histogram extension 4.1 stacked histogram 4.2 decompose histogram 5. Python plots line chart coordinates cannot display minus signs
Just add the following code
Import matplotlibmatplotlib.rcParams ['axes.unicode_minus'] = Falseplt.rcParams [' axes.unicode_minus'] = False6. Python axis displays the Chinese character plt.rcParams ['font.sans-serif'] = [' SimHei'] # add boldface as drawing font all the contents of this article "what are the common commands for Python drawing". 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.