Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import matplotlib.pyplot as plt
- plt.figure()
- x = np.arange(-4.0, 4.0, 0.03)
- y = np.arange(-4.0, 4.0, 0.03)
- X, Y = np.meshgrid(x, y)
- coef = 2.0
- def f(x, y):
- # return 10.0 * 2 + (x**2 - 10 * np.cos(2*np.pi*x)) + (y**2 - 10 * np.cos(2*np.pi*y))
- return 10.0 * 2 + (x**2 - 10 * np.cos(2*np.pi*x)) + ((coef*y)**2 - 10 * np.cos(2*np.pi*(coef*y)))
- def make_Z():
- d = len(x)
- Z = np.zeros([d, d])
- for i in range(d):
- for j in range(d):
- Z[i, j] = f(x[i], y[j])
- return Z
- # Z = 10.0 * 2 + (X**2 - 10 * np.cos(2*np.pi*X)) + (Y**2 - 10 * np.cos(2*np.pi*Y))
- Z = make_Z()
- print("Z:{}".format(Z))
- plt.pcolormesh(X, Y, Z, cmap='hsv') # 等高線図の生成。cmapで色付けの規則を指定する。
- #plt.pcolor(X, Y, Z, cmap='hsv') # 等高線図の生成。cmapで色付けの規則を指定する。
- pp=plt.colorbar (orientation="vertical") # カラーバーの表示
- pp.set_label("Label", fontname="Arial", fontsize=24) #カラーバーのラベル
- plt.xlabel('X', fontsize=24)
- plt.ylabel('Y', fontsize=24)
- plt.savefig('a.pdf')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement