In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to fill in the diagram in Matplotlib. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
Background introduction
You will learn how to populate the line graph in Matplotlib. Not only does this make our chart look more professional, but we can also add useful information by filling areas based on specific thresholds.
Getting started example
Next, let's take a look at an example: read a data.csv file as a medium company table that counts all developers, Python developers, and JavaScript developers of different ages. We use a filled area to show that the salary age of Python developers is higher than that of all developers (yellow area), as well as the age of salaried people below all developers (red area). The csv file is roughly as follows:
The specific code is as follows:
Import pandas as pdfrom matplotlib import pyplot as pltfrom matplotlib import rcParams# sets the chart font to prevent Chinese garbled rcParams ['font.family'] =' Microsoft YaHei'rcParams ['font.sans-serif'] =' Microsoft YaHei'
Data = pd.read_csv ('data.csv') ages = data [' Age'] dev_salaries = data ['All_Devs'] py_salaries = data [' Python'] js_salaries = data ['JavaScript']
Plt.plot (salary for all ages,dev_salaries,color='#444444', linestyle='--',label=' developers') plt.plot (salary for ages,py_salaries,label='Python developers) # use the fill_between () method to populate the area # where when the python development salary is greater than all development salaries # interpolate defines the fill area as Ture#color: area color # alpha: set transparency plt.fill_between (ages,py_salaries, dev_salaries Where= (py_salaries > dev_salaries), interpolate=True,color='yellow',alpha=0.25, label=' above the specified salary') # use the fill_between () method to fill the area # where when the python development salary is less than or equal to all development salaries # interpolate defines the fill area as Ture#color: area color # alpha: set transparency plt.fill_between (ages,py_salaries,dev_salaries, where= (py_salaries)
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.