【项目实战】P2P金融数据指标分析
生活随笔
收集整理的這篇文章主要介紹了
【项目实战】P2P金融数据指标分析
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
python:P2P金融數據指標分析
# -*- coding: utf-8 -*- """ Created on Wed Jul 4 17:31:47 2018@author: 孫正陽 """ #@導入功能模塊數據包 import numpy as np import pandas as pd #import matplotlib.pyplot as plt #plt.rcParams["font.sans-serif"] = ["SimHei"] #plt.rcParams['axes.unicode_minus'] = False import warnings warnings.filterwarnings('ignore')import os os.chdir('C:/Users/A3/Desktop/') df= pd.read_excel('指標畫圖.xlsx',sheetname = 0,header = 0,index_col = [0]) data = pd.DataFrame(df) #============================================================================== # timeStamp = df['time'] # tm = time.strptime(timeStamp, '%Y-%m-%d %H:%M:%S') # tm # timeArray = time.localtime(timeStamp) # otherStyleTime = time.strftime("%Y--%m--%d %H:%M:%S", timeArray) # otherStyleTime # 2013--10--10 23:40:00 #============================================================================== from bokeh.plotting import figure,show,output_file from bokeh.models import ColumnDataSource from bokeh.models import HoverTool from bokeh.layouts import gridplot from bokeh.models.annotations import Span from bokeh.models.annotations import Label #from bokeh.layouts import gridplot#數據統計 source = ColumnDataSource(data) time_lst = data.index.tolist() #創建數據 output_file('weight_add.html') hover = HoverTool(tooltips = [('指標',"@整體首逾率")]) p = figure(plot_width = 1000,plot_height =450,title = '音速分期C~M1%指標走勢',x_axis_label = '時間趨勢', y_axis_label = 'C~M1%', x_range = time_lst,y_range = [0,0.3],tools = [hover,'pan,wheel_zoom,box_zoom,save,reset,help'],# 工具欄位置toolbar_location='above' # 工具欄位置:"above","below","left","right"))p.line(x = 'time',y = '整體首逾率',source = source,legend = 'C~M1%-時間線',line_width = 1,line_alpha = 0.8,line_color = 'black',line_dash = [10,4]) p.circle(x = 'time',y = '整體首逾率',source = source,size = 10,color = 'green',alpha = 0.8) p.title.text_color = "white" #顏色 p.title.text_font = "times" #字體 p.title.text_font_style = "italic" #風格 p.title.text_font_size= '18pt' p.title.background_fill_color = "black" #背景顏色# 設置標題p.outline_line_width = 5 # 邊框線寬 p.outline_line_alpha = 0.3 # 邊框線透明度 p.outline_line_color = "green" # 邊框線顏色p.background_fill_color = "beige" # 繪圖空間背景顏色 p.background_fill_alpha = 0.5 # 繪圖空間背景透明度p.border_fill_color = "whitesmoke" # 外邊界背景顏色 p.min_border_left = 80 # 外邊界背景 - 左邊寬度 p.min_border_right = 80 # 外邊界背景 - 右邊寬度 p.min_border_top = 30 # 外邊界背景 - 上寬度 p.min_border_bottom = 10 # 外邊界背景 - 下寬度 #設置邊界背景p.yaxis.axis_line_width = 2 #線寬 p.yaxis.axis_line_color = "red" #軸線顏色 # 設置軸線 p.axis.minor_tick_in = 5 # 刻度往繪圖區域內延伸長度 p.axis.minor_tick_out = 3 # 刻度往繪圖區域外延伸長度 # 設置刻度 #p.yaxis.bounds = (86, 100) # 設置軸線范圍p.xaxis.axis_label = "時間" p.xaxis.axis_label_text_color = "#aa6666" p.xaxis.axis_label_standoff = 30 # 設置標簽名稱、字體顏色、偏移距離p.yaxis.axis_label = "C~M1%" p.yaxis.axis_label_text_font_style = "italic" # 設置標簽名稱、字體p.yaxis.major_label_text_color = "orange" p.yaxis.major_label_orientation = "vertical" # 設置y軸線:標簽、字體顏色、字體角度p.xgrid.grid_line_color = None # 顏色設置,None時則不顯示p.ygrid.grid_line_alpha = 0.2 p.ygrid.grid_line_dash = [6, 4] # 設置透明度,虛線設置 # dash → 通過設置間隔來做虛線 # minor_line → 設置次軸線 p.xgrid.minor_grid_line_color = 'navy' p.xgrid.minor_grid_line_alpha = 0.1 #p = gridplot([p]) p.grid.bounds = (-1, 1) # 設置填充邊界p.legend.location = "top_left" # 設置圖例位置:"top_left"、"top_center"、"top_right" (the default)、"center_right"、"bottom_right"、"bottom_center" # "bottom_left"、"center_left"、"center"p.legend.orientation = "vertical" # 設置圖例排列方向:"vertical" (默認)or "horizontal"p.legend.label_text_font = "times" p.legend.label_text_font_style = "italic" # 斜體 p.legend.label_text_color = "navy" p.legend.label_text_font_size = '12pt' # 設置圖例:字體、風格、顏色、字體大小p.legend.border_line_width = 2 p.legend.border_line_color = "navy" p.legend.border_line_alpha = 0.5 # 設置圖例外邊線:寬度、顏色、透明度p.legend.background_fill_color = "gray" p.legend.background_fill_alpha = 0.2 # 設置圖例背景:顏色、透明度upper = Span(location=0.1, # 設置位置,對應坐標值dimension='width', # 設置方向,width為橫向,height為縱向 line_color='firebrick',line_width=1,# 設置線顏色、線寬line_dash = [5,2]) p.add_layout(upper) # 繪制輔助線1 lower = Span(location=0.05, dimension='width', line_color='olive', line_width=1,line_dash = [5,2]) p.add_layout(lower) # 繪制輔助線2#============================================================================== # label1 = Label(x=6, y=86, # 標注注釋位置 # x_offset=12, # x偏移,同理y_offset # text="跑了10km", # 注釋內容 # text_font_size="12pt", # 字體大小 # border_line_color="green", # background_fill_color="gray", # background_fill_alpha = 0.5 # 背景線條顏色、背景顏色、透明度 # ) # p.add_layout(label1) # label2 = Label(x=7, y=87.5, # 標注注釋位置 # x_offset=12, # x偏移,同理y_offset # text="吃了不少高熱量食物", # 注釋內容 # text_font_size="12pt", # 字體大小 # border_line_color="red", # background_fill_color="gray", # background_fill_alpha = 0.5 # 背景線條顏色、背景顏色、透明度 # ) # p.add_layout(label2) # label3 = Label(x=11, y=86, # 標注注釋位置 # x_offset=12, # x偏移,同理y_offset # text="跑步5km", # 注釋內容 # text_font_size="12pt", # 字體大小 # border_line_color="green", # background_fill_color="gray", # background_fill_alpha = 0.5 # 背景線條顏色、背景顏色、透明度 # ) # p.add_layout(label3) # label4 = Label(x=13, y=87, # 標注注釋位置 # x_offset=12, # x偏移,同理y_offset # text="晚餐大量進食", # 注釋內容 # text_font_size="12pt", # 字體大小 # border_line_color="red", # background_fill_color="gray", # background_fill_alpha = 0.5 # 背景線條顏色、背景顏色、透明度 # ) # p.add_layout(label4) #============================================================================== # 繪制注釋#p = gridplot([p])show(p) print('finished!') 《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀總結
以上是生活随笔為你收集整理的【项目实战】P2P金融数据指标分析的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【项目实战】SQL :部门花名册PBI展
- 下一篇: 【Python】KNN简单的判别预测