This commit is contained in:
guanjihuan 2021-12-19 15:48:03 +08:00
parent b5ee3b910c
commit de472b9df5
3 changed files with 10 additions and 10 deletions

View File

@ -107,9 +107,9 @@ guan.write_one_dimensional_data(x_array, y_array, filename='a')
guan.write_two_dimensional_data(x_array, y_array, matrix, filename='a') guan.write_two_dimensional_data(x_array, y_array, matrix, filename='a')
# plot figures # Source code: https://py.guanjihuan.com/plot_figures # plot figures # Source code: https://py.guanjihuan.com/plot_figures
guan.plot(x_array, y_array, xlabel='x', ylabel='y', title='', filename='a', show=1, save=0, type='', y_min=None, y_max=None, linewidth=None, markersize=None) guan.plot(x_array, y_array, xlabel='x', ylabel='y', title='', filename='a', show=1, save=0, format='jpg', dpi=300, type='', y_min=None, y_max=None, linewidth=None, markersize=None)
guan.plot_3d_surface(x_array, y_array, matrix, xlabel='x', ylabel='y', zlabel='z', title='', filename='a', show=1, save=0, z_min=None, z_max=None) guan.plot_3d_surface(x_array, y_array, matrix, xlabel='x', ylabel='y', zlabel='z', title='', filename='a', show=1, save=0, format='jpg', dpi=300, z_min=None, z_max=None)
guan.plot_contour(x_array, y_array, matrix, xlabel='x', ylabel='y', title='', filename='a', show=1, save=0) guan.plot_contour(x_array, y_array, matrix, xlabel='x', ylabel='y', title='', filename='a', show=1, save=0, format='jpg', dpi=300)
# others # Source code: https://py.guanjihuan.com/source-code/others # others # Source code: https://py.guanjihuan.com/source-code/others
guan.download_with_scihub(address=None, num=1) guan.download_with_scihub(address=None, num=1)

View File

@ -1,7 +1,7 @@
[metadata] [metadata]
# replace with your username: # replace with your username:
name = guan name = guan
version = 0.0.31 version = 0.0.32
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

View File

@ -4,7 +4,7 @@
import numpy as np import numpy as np
def plot(x_array, y_array, xlabel='x', ylabel='y', title='', filename='a', show=1, save=0, type='', y_min=None, y_max=None, linewidth=None, markersize=None): def plot(x_array, y_array, xlabel='x', ylabel='y', title='', filename='a', show=1, save=0, format='jpg', dpi=300, type='', y_min=None, y_max=None, linewidth=None, markersize=None):
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=0.20, left=0.18)
@ -23,12 +23,12 @@ def plot(x_array, y_array, xlabel='x', ylabel='y', title='', filename='a', show=
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:
plt.savefig(filename+'.jpg', dpi=300) plt.savefig(filename+format, dpi=dpi)
if show == 1: if show == 1:
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='', filename='a', show=1, save=0, z_min=None, z_max=None): def plot_3d_surface(x_array, y_array, matrix, xlabel='x', ylabel='y', zlabel='z', title='', filename='a', show=1, save=0, format='jpg', dpi=300, z_min=None, z_max=None):
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
@ -62,12 +62,12 @@ def plot_3d_surface(x_array, y_array, matrix, xlabel='x', ylabel='y', zlabel='z'
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:
plt.savefig(filename+'.jpg', dpi=300) plt.savefig(filename+format, dpi=dpi)
if show == 1: if show == 1:
plt.show() plt.show()
plt.close('all') plt.close('all')
def plot_contour(x_array, y_array, matrix, xlabel='x', ylabel='y', title='', filename='a', show=1, save=0): def plot_contour(x_array, y_array, matrix, xlabel='x', ylabel='y', title='', filename='a', show=1, save=0, 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.16)
@ -85,7 +85,7 @@ def plot_contour(x_array, y_array, matrix, xlabel='x', ylabel='y', title='', fil
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:
plt.savefig(filename+'.jpg', dpi=300) plt.savefig(filename+format, dpi=dpi)
if show == 1: if show == 1:
plt.show() plt.show()
plt.close('all') plt.close('all')