In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
Xiaobian to share with you matplotlib Chinese display of the chart example analysis, I hope you read this article after all have something to gain, let's discuss it together!
Prepare #Import Package and Configure Chinese
%matplotlib inline
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.font_manager import FontProperties
# simhei.ttf can replace any Chinese ttf font, note that the path is correct
font = FontProperties(fname='simhei.ttf', size=16)
#Set matplotlib to display Chinese and minus sign normally
matplotlib.rcParams['font.sans-serif']=['SimHei']
matplotlib.rcParams['axes.unicode_minus']=False
Histogram #Generate canvas
plt.figure(figsize=(10, 6), dpi=80)
#abscissa city name
x = ['Heilongjiang',' Hongkong','Taiwan',' Shanghai','Inner Mongolia',' Shanxi','Beijing',' Shanxi','Guangdong',' Macao']
#Number of existing diagnoses on the day
y = [339, 222, 116, 54, 52, 50, 46, 37, 26, 12]
plt.bar(x,y,width=0.5)
#Title
plt.title ('2020.04.29 existing diagnoses top10', fontproperties=font)
#abscissa label
plt.xlabel ('top10 City', fontproperties=font)
#Coordinates label
plt.ylabel ('Number of existing diagnostics', fontproperties=font)
#Make coordinate scales
plt.xticks(x, fontproperties=font)
plt.show()
pie chart #generate canvas
plt.figure(figsize=(10, 6), dpi=80)
#abscissa city name
labels = ['Heilongjiang',' Hongkong','Taiwan',' Shanghai','Inner Mongolia',' Shanxi','Beijing',' Shanxi','Guangdong',' Macao']
#Number of existing diagnoses on the day
sizes = [339, 222, 116, 54, 52, 50, 46, 37, 26, 12]
explode = np.linspace(0, 0.4, 10)
plt.pie(sizes, explode=explode, labels=labels, autopct='%1.1f%%', shadow=False, startangle=-45, textprops={'fontproperties':font})
plt.title("2020.04.29 Number of existing diagnoses top10 city proportion", fontproperties=font)
#Legend
plt.legend(loc='right', bbox_to_anchor=[0.75, 0.4, 0.5, 0.5], prop=font)
plt.show()
After reading this article, I believe you have a certain understanding of "matplotlib Chinese display chart example analysis," if you want to know more related knowledge, welcome to pay attention to the industry information channel, thank you for reading!
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.