In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 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.
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.