雷达图
import numpy as np
import scipy. stats as stats
import matplotlib. style as style
import matplotlib. pyplot as plt
import seaborn as sns
import warnings
warnings. filterwarnings( 'ignore' )
% matplotlib inline
style. use( 'fivethirtyeight' )
plt. rcParams[ 'figure.figsize' ] = ( 9 , 9 )
plt. rcParams[ 'figure.dpi' ] = 100
plt. rcParams[ 'font.family' ] = [ 'SimHei' ]
plt. rcParams[ 'axes.unicode_minus' ] = False
labels = np. array( [ '推塔' , '生存' , '承受伤害' , '经济' , '团战' , '输出' ] )
dataLen = labels. size
data = np. array( [ 1 , 6 , 3 , 7 , 4 , 8 ] )
data = np. concatenate( ( data, [ data[ 0 ] ] ) )
angles = np. linspace( 0 , 2 * np. pi, dataLen, endpoint= False )
angles = np. concatenate( ( angles, [ angles[ 0 ] ] ) )
fig = plt. figure( )
ax = fig. add_subplot( 111 , polar= True )
ax. plot( angles, data, 'co-' , lw= 2 )
ax. fill( angles, data, facecolor= 'c' , alpha= .2 )
ax. set_thetagrids( angles * 180 / np. pi, labels, fontproperties= 'SimHei' , size= 20 )
ax. set_title( "李白" )
K线图(蜡烛图)
import pandas as pd
import seaborn as sns
import matplotlib. pyplot as plt
import matplotlib. dates as dates
import mpl_finance as mf
plt. rcParams[ 'figure.figsize' ] = [ 18 , 6 ]
sns. set_style( 'darkgrid' , { 'font.sans-serif' : [ 'SimHei' , 'Arial' ] } )
df_stock = pd. read_excel( './data/茅台股份.xlsx' )
df_stock. set_index( '日期' , inplace= True )
new_df = df_stock. loc[ : , [ '开盘' , '最高' , '最低' , '收盘' ] ]
new_df = new_df. iloc[ : 100 ]
zip_data = zip ( dates. date2num( new_df. index. to_pydatetime( ) ) , new_df. 开盘, new_df. 最高, new_df. 最低, new_df. 收盘)
ax = plt. gca( )
plt. title( '茅台股份OHLC-K线图' )
mf. candlestick_ohlc( ax, zip_data, colorup= 'r' , colordown= 'g' , width= 5 )
ax. xaxis_date( )
plt. xticks( rotation= 45 )
绘制OHLC线图
import pandas as pd
import seaborn as sns
import matplotlib. pyplot as plt
plt. rcParams[ 'figure.figsize' ] = [ 18 , 6 ]
sns. set_style( 'darkgrid' , { 'font.sans-serif' : [ 'SimHei' , 'Arial' ] } )
df_stock = pd. read_excel( './data/茅台股份.xlsx' )
df_stock. set_index( '日期' , inplace= True )
new_df = df_stock. loc[ : , [ '开盘' , '最高' , '最低' , '收盘' ] ]
sns. lineplot( data= new_df. iloc[ : 150 ] )