version 0.0.77
This commit is contained in:
parent
fe66db52b8
commit
612745555a
@ -242,11 +242,11 @@ guan.write_two_dimensional_data(x_array, y_array, matrix, filename='a', format='
|
|||||||
|
|
||||||
# plot figures
|
# plot figures
|
||||||
|
|
||||||
guan.plot(x_array, y_array, xlabel='x', ylabel='y', title='', show=1, save=0, filename='a', format='jpg', dpi=300, type='', y_min=None, y_max=None, linewidth=None, markersize=None)
|
guan.plot(x_array, y_array, xlabel='x', ylabel='y', title='', fontsize=20, labelsize=20, show=1, save=0, filename='a', format='jpg', dpi=300, type='', y_min=None, y_max=None, linewidth=None, markersize=None, adjust_bottom=0.2, adjust_left=0.2)
|
||||||
|
|
||||||
guan.plot_3d_surface(x_array, y_array, matrix, xlabel='x', ylabel='y', zlabel='z', title='', show=1, save=0, filename='a', format='jpg', dpi=300, z_min=None, z_max=None, rcount=100, ccount=100)
|
guan.plot_3d_surface(x_array, y_array, matrix, xlabel='x', ylabel='y', zlabel='z', title='', fontsize=20, labelsize=15, show=1, save=0, filename='a', format='jpg', dpi=300, z_min=None, z_max=None, rcount=100, ccount=100)
|
||||||
|
|
||||||
guan.plot_contour(x_array, y_array, matrix, xlabel='x', ylabel='y', title='', show=1, save=0, filename='a', format='jpg', dpi=300)
|
guan.plot_contour(x_array, y_array, matrix, xlabel='x', ylabel='y', title='', fontsize=20, labelsize=15, show=1, save=0, filename='a', format='jpg', dpi=300)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
# replace with your username:
|
# replace with your username:
|
||||||
name = guan
|
name = guan
|
||||||
version = 0.0.76
|
version = 0.0.77
|
||||||
author = guanjihuan
|
author = guanjihuan
|
||||||
author_email = guanjihuan@163.com
|
author_email = guanjihuan@163.com
|
||||||
description = An open source python package
|
description = An open source python package
|
||||||
|
@ -1506,22 +1506,22 @@ def write_two_dimensional_data(x_array, y_array, matrix, filename='a', format='t
|
|||||||
|
|
||||||
# Module 11: plot figures
|
# Module 11: plot figures
|
||||||
|
|
||||||
def plot(x_array, y_array, xlabel='x', ylabel='y', title='', show=1, save=0, filename='a', format='jpg', dpi=300, type='', y_min=None, y_max=None, linewidth=None, markersize=None):
|
def plot(x_array, y_array, xlabel='x', ylabel='y', title='', fontsize=20, labelsize=20, show=1, save=0, filename='a', format='jpg', dpi=300, type='', y_min=None, y_max=None, linewidth=None, markersize=None, adjust_bottom=0.2, adjust_left=0.2):
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
fig, ax = plt.subplots()
|
fig, ax = plt.subplots()
|
||||||
plt.subplots_adjust(bottom=0.20, left=0.18)
|
plt.subplots_adjust(bottom=adjust_bottom, left=adjust_left)
|
||||||
ax.plot(x_array, y_array, type, linewidth=linewidth, markersize=markersize)
|
ax.plot(x_array, y_array, type, linewidth=linewidth, markersize=markersize)
|
||||||
ax.grid()
|
ax.grid()
|
||||||
ax.set_title(title, fontsize=20, fontfamily='Times New Roman')
|
ax.set_title(title, fontsize=fontsize, fontfamily='Times New Roman')
|
||||||
ax.set_xlabel(xlabel, fontsize=20, fontfamily='Times New Roman')
|
ax.set_xlabel(xlabel, fontsize=fontsize, fontfamily='Times New Roman')
|
||||||
ax.set_ylabel(ylabel, fontsize=20, fontfamily='Times New Roman')
|
ax.set_ylabel(ylabel, fontsize=fontsize, fontfamily='Times New Roman')
|
||||||
if y_min!=None or y_max!=None:
|
if y_min!=None or y_max!=None:
|
||||||
if y_min==None:
|
if y_min==None:
|
||||||
y_min=min(y_array)
|
y_min=min(y_array)
|
||||||
if y_max==None:
|
if y_max==None:
|
||||||
y_max=max(y_array)
|
y_max=max(y_array)
|
||||||
ax.set_ylim(y_min, y_max)
|
ax.set_ylim(y_min, y_max)
|
||||||
ax.tick_params(labelsize=20)
|
ax.tick_params(labelsize=labelsize)
|
||||||
labels = ax.get_xticklabels() + ax.get_yticklabels()
|
labels = ax.get_xticklabels() + ax.get_yticklabels()
|
||||||
[label.set_fontname('Times New Roman') for label in labels]
|
[label.set_fontname('Times New Roman') for label in labels]
|
||||||
if save == 1:
|
if save == 1:
|
||||||
@ -1530,7 +1530,7 @@ def plot(x_array, y_array, xlabel='x', ylabel='y', title='', show=1, save=0, fil
|
|||||||
plt.show()
|
plt.show()
|
||||||
plt.close('all')
|
plt.close('all')
|
||||||
|
|
||||||
def plot_3d_surface(x_array, y_array, matrix, xlabel='x', ylabel='y', zlabel='z', title='', show=1, save=0, filename='a', format='jpg', dpi=300, z_min=None, z_max=None, rcount=100, ccount=100):
|
def plot_3d_surface(x_array, y_array, matrix, xlabel='x', ylabel='y', zlabel='z', title='', fontsize=20, labelsize=15, show=1, save=0, filename='a', format='jpg', dpi=300, z_min=None, z_max=None, rcount=100, ccount=100):
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
from matplotlib import cm
|
from matplotlib import cm
|
||||||
from matplotlib.ticker import LinearLocator
|
from matplotlib.ticker import LinearLocator
|
||||||
@ -1543,10 +1543,10 @@ def plot_3d_surface(x_array, y_array, matrix, xlabel='x', ylabel='y', zlabel='z'
|
|||||||
elif len(matrix.shape) == 3:
|
elif len(matrix.shape) == 3:
|
||||||
for i0 in range(matrix.shape[2]):
|
for i0 in range(matrix.shape[2]):
|
||||||
surf = ax.plot_surface(x_array, y_array, matrix[:,:,i0], rcount=rcount, ccount=ccount, cmap=cm.coolwarm, linewidth=0, antialiased=False)
|
surf = ax.plot_surface(x_array, y_array, matrix[:,:,i0], rcount=rcount, ccount=ccount, cmap=cm.coolwarm, linewidth=0, antialiased=False)
|
||||||
ax.set_title(title, fontsize=20, fontfamily='Times New Roman')
|
ax.set_title(title, fontsize=fontsize, fontfamily='Times New Roman')
|
||||||
ax.set_xlabel(xlabel, fontsize=20, fontfamily='Times New Roman')
|
ax.set_xlabel(xlabel, fontsize=fontsize, fontfamily='Times New Roman')
|
||||||
ax.set_ylabel(ylabel, fontsize=20, fontfamily='Times New Roman')
|
ax.set_ylabel(ylabel, fontsize=fontsize, fontfamily='Times New Roman')
|
||||||
ax.set_zlabel(zlabel, fontsize=20, fontfamily='Times New Roman')
|
ax.set_zlabel(zlabel, fontsize=fontsize, fontfamily='Times New Roman')
|
||||||
ax.zaxis.set_major_locator(LinearLocator(5))
|
ax.zaxis.set_major_locator(LinearLocator(5))
|
||||||
ax.zaxis.set_major_formatter('{x:.2f}')
|
ax.zaxis.set_major_formatter('{x:.2f}')
|
||||||
if z_min!=None or z_max!=None:
|
if z_min!=None or z_max!=None:
|
||||||
@ -1555,12 +1555,12 @@ def plot_3d_surface(x_array, y_array, matrix, xlabel='x', ylabel='y', zlabel='z'
|
|||||||
if z_max==None:
|
if z_max==None:
|
||||||
z_max=matrix.max()
|
z_max=matrix.max()
|
||||||
ax.set_zlim(z_min, z_max)
|
ax.set_zlim(z_min, z_max)
|
||||||
ax.tick_params(labelsize=15)
|
ax.tick_params(labelsize=labelsize)
|
||||||
labels = ax.get_xticklabels() + ax.get_yticklabels() + ax.get_zticklabels()
|
labels = ax.get_xticklabels() + ax.get_yticklabels() + ax.get_zticklabels()
|
||||||
[label.set_fontname('Times New Roman') for label in labels]
|
[label.set_fontname('Times New Roman') for label in labels]
|
||||||
cax = plt.axes([0.80, 0.15, 0.05, 0.75])
|
cax = plt.axes([0.8, 0.1, 0.05, 0.8])
|
||||||
cbar = fig.colorbar(surf, cax=cax)
|
cbar = fig.colorbar(surf, cax=cax)
|
||||||
cbar.ax.tick_params(labelsize=15)
|
cbar.ax.tick_params(labelsize=labelsize)
|
||||||
for l in cbar.ax.yaxis.get_ticklabels():
|
for l in cbar.ax.yaxis.get_ticklabels():
|
||||||
l.set_family('Times New Roman')
|
l.set_family('Times New Roman')
|
||||||
if save == 1:
|
if save == 1:
|
||||||
@ -1569,21 +1569,21 @@ def plot_3d_surface(x_array, y_array, matrix, xlabel='x', ylabel='y', zlabel='z'
|
|||||||
plt.show()
|
plt.show()
|
||||||
plt.close('all')
|
plt.close('all')
|
||||||
|
|
||||||
def plot_contour(x_array, y_array, matrix, xlabel='x', ylabel='y', title='', show=1, save=0, filename='a', format='jpg', dpi=300):
|
def plot_contour(x_array, y_array, matrix, xlabel='x', ylabel='y', title='', fontsize=20, labelsize=15, show=1, save=0, filename='a', format='jpg', dpi=300):
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
fig, ax = plt.subplots()
|
fig, ax = plt.subplots()
|
||||||
plt.subplots_adjust(bottom=0.2, right=0.75, left = 0.16)
|
plt.subplots_adjust(bottom=0.2, right=0.75, left=0.2)
|
||||||
x_array, y_array = np.meshgrid(x_array, y_array)
|
x_array, y_array = np.meshgrid(x_array, y_array)
|
||||||
contour = ax.contourf(x_array,y_array,matrix,cmap='jet')
|
contour = ax.contourf(x_array,y_array,matrix,cmap='jet')
|
||||||
ax.set_title(title, fontsize=20, fontfamily='Times New Roman')
|
ax.set_title(title, fontsize=fontsize, fontfamily='Times New Roman')
|
||||||
ax.set_xlabel(xlabel, fontsize=20, fontfamily='Times New Roman')
|
ax.set_xlabel(xlabel, fontsize=fontsize, fontfamily='Times New Roman')
|
||||||
ax.set_ylabel(ylabel, fontsize=20, fontfamily='Times New Roman')
|
ax.set_ylabel(ylabel, fontsize=fontsize, fontfamily='Times New Roman')
|
||||||
ax.tick_params(labelsize=15)
|
ax.tick_params(labelsize=labelsize)
|
||||||
labels = ax.get_xticklabels() + ax.get_yticklabels()
|
labels = ax.get_xticklabels() + ax.get_yticklabels()
|
||||||
[label.set_fontname('Times New Roman') for label in labels]
|
[label.set_fontname('Times New Roman') for label in labels]
|
||||||
cax = plt.axes([0.78, 0.17, 0.08, 0.71])
|
cax = plt.axes([0.8, 0.2, 0.05, 0.68])
|
||||||
cbar = fig.colorbar(contour, cax=cax)
|
cbar = fig.colorbar(contour, cax=cax)
|
||||||
cbar.ax.tick_params(labelsize=15)
|
cbar.ax.tick_params(labelsize=labelsize)
|
||||||
for l in cbar.ax.yaxis.get_ticklabels():
|
for l in cbar.ax.yaxis.get_ticklabels():
|
||||||
l.set_family('Times New Roman')
|
l.set_family('Times New Roman')
|
||||||
if save == 1:
|
if save == 1:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user