cool python example

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
dx =0.01 ;dy = 0.01
x = np.arange(-0.2,0.2,dx)
y = np.arange(-0.2,0.2,dy)
X,Y = np.meshgrid(x,y)
def f(x,y):
    return (1 - y**5 + x**5) * np.exp(-x**2-y**2)
C = plt.contour(X,Y,f(X,Y),8,colors = 'black')
plt.contourf(X,Y,f(X,Y),8)
plt.clabel(C,inline=1,fontsize=10)
plt.show()

 

运行结果:

 

cool python example_第1张图片

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
dx =0.01 ;dy = 0.01
x = np.arange(-0.2,0.2,dx)
y = np.arange(-0.2,0.2,dy)
X,Y = np.meshgrid(x,y)
def f(x,y):
    return (1 - y**5 + x**5) * np.exp(-x**2-y**2)
C = plt.contour(X,Y,f(X,Y),8,colors = 'black')
plt.contourf(X,Y,f(X,Y),8,cmap=plt.cm.hot)
plt.clabel(C,inline=1,fontsize=10)
plt.show()

运行结果:

cool python example_第2张图片

import matplotlib.pyplot as plt
import numpy as np
N = 8
theta = np.arange(0.,2*np.pi,2*np.pi/N)
radii = np.array([4,7,5,3,1,5,6,7])
plt.axes([0.025,0.025,0.95,0.95],polar=True)
colors = np.array(['#4bb2c5','#c5b47f','#EAA228','#579575','#839557','#958c12','#953579','#4b5de4'])
bars = plt.bar(theta,radii,width=(2*np.pi/N),bottom=0.0,color=colors)
plt.show()

运行结果:

cool python example_第3张图片

你可能感兴趣的:(Python)