# -*- coding: utf-8 -*-
"""
Created on Sun Jun 2 19:23:26 2019
@author: User
"""
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm #导入着色模块
u=np.linspace(-3,3,30)
print(u)
x,y=np.meshgrid(u,u)
r=0.6;mux=0;muy=0;sx=1;sy=1;
z=(1/(2*3.141592697*sx*sy*np.sqrt(1-r*r)))*np.exp((-1/(2*(1-r*r)))*(((x-mux)**2)/(sx**2)-2*r*(x-mux)*(y-muy)/(sx*sy)+((y-muy)**2)/(sx**2)))
fig=plt.figure()
ax=fig.add_subplot(111,projection='3d')
ax.plot_surface(x,y,z,rstride=1,cstride=1,cmap=cm.Greys)
plt.show()
运行:
绘制反映单个变量变动特征的折线图:
# -*- coding: utf-8 -*-
"""
Created on Sun Jun 2 20:03:32 2019
@author: User
"""
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
plt.plot(np.random.randn(100),linewidth=2.0)
plt.show
运行:
绘制开盘价折线图:
# -*- coding: utf-8 -*-
"""
Created on Sun Jun 2 20:07:46 2019
@author: User
"""
import numpy as np
import pandas as pd
import matplotlib as mpl
import matplotlib.pyplot as plt
print('\n pd.read_table:')
jddf=pd.read_csv('data\stock.csv',sep=',',header=None,
names=['id','time','code','open_p','colse_p','low_p','vol','high_p','col'])
plt.plot(jddf['open_p'])
plt.show
运行: