In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "how to generate a line chart based on Python list data", the content is simple and easy to understand, organized clearly, I hope to help you solve doubts, let Xiaobian lead you to study and learn "how to generate a line chart based on Python list data" this article bar.
code
The following is a sample code.
#!/ user/bin/env python# coding= utf-8 ""@project : csdn@author : swordsman Aliang_ALiang@file : draw_pic.py@ide : PyCharm@time : 2022-03-23 09:38:28"""import pandas as pdfrom matplotlib import pyplot as plt _dates = ['2022-03-22 16:45:08', '2022-03-22 16:46:08', '2022-03-22 16:47:08', '2022-03-22 16:48:08', '2022-03-22 16:49:08', '2022-03-22 16:50:08', '2022-03-22 16:51:08', '2022-03-22 16:52:08', '2022-03-22 16:53:08', '2022-03-22 16:54:08']_data1 = [1, 2, 4, 6, 3, 2, 5, 7, 8, 0]_data2 = [0, 9, 8, 2, 1, 0, 6, 5, 2, 1] di = pd.DatetimeIndex(_dates, dtype='datetime64[ns]', freq=None) pd.DataFrame({'data1': _data1}, index=di).plot.line() #Graph abscissa defaults to data index.# plt.savefig(r'data/p1.png', dpi=200)plt.show() #Display currently compiling image pd.DataFrame({'data1': _data1, 'data2': _data2}, index=di).plot.line() #Graph abscissa defaults to data index.# plt.savefig(r'data/p2.png', dpi=200)plt.show() #Show the image code description currently being compiled
1. Time list of x axis: _dates, two sets of list data are prepared, which need to correspond to the number of date lists.
2. Two pictures were made. The second picture was mainly two lines generated on one picture.
verify the effect
The above is "How to generate a line chart from list data based on Python". Thank you for reading this article! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to 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.