In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces Python how to draw a visualization map, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
Preface
After loading the data:
# time series trend chart import csvimport matplotlibimport numpy as npimport pandas as pdfrom datetime import datetimefrom matplotlibimport pyplot as plt# reads CSV file data file1='D:\\ data. Csv'for file2 in file1: print ('read file:% s'% file2) try: with open (file1) as f: # Open this file And store the result file object in f reader=csv.reader (f) # create a reader reader header_row=next (reader) # return the next line of date,r,VaR= in the file [], [] # declare the storage date List of most values for row in reader: date1=datetime.strptime (row [0]) '% Y _ date1% m _ r.append% d') # convert date data to datetime object date.append (date1) # Storage date r1=float (row [3]) # convert string to numeric r.append (R1) # maximum storage temperature VaR1=float (row [2]) VaR .append (VaR1) # minimum storage temperature except Exception as e: print ('read error' File2,':', e) zhfont1 = matplotlib.font_manager.FontProperties\ (fname= "D:\\ simhei.ttf") # define font matplotlib.rcParams ['axes.unicode_minus'] = False # solve the problem of minus sign'-'display as square # draw image fig=plt.figure (dpi=128,figsize= (8line 5)) plt.plot (date,r,label='r',linewidth=2,c='blue',alpha=1) # Transparency of the color specified by argument alpha 0 means completely transparent 1 (default) completely opaque plt.plot (date,VaR,'--',label='95%VaR',c='m',linewidth=2,alpha=1) plt.fill_between (date,r,VaR,facecolor='blue',alpha=0.1) # fill the chart area with color plt.title ("differential rate of return and its risk time series trend chart, fontproperties=zhfont1,fontsize=12) # chart coordinates set plt.xlabel (" time ", fontproperties=zhfont1,fontsize=10) plt.ylabel (" numerical ", fontproperties=zhfont1 Fontsize=10) plt.tick_params (axis='both',which='major',labelsize=10) plt.legend () # legend shows fig.autofmt_xdate () # draw oblique date label plt.grid (True) # add grid True initials plt.show () # display image Thank you for reading this article carefully. I hope the article "how to draw a visual map for Python" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
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.