python代码 y轴反向输出

import numpy as np
import matplotlib.pyplot as plt

# Line width, marker size, font size, font name
lw = 1.0
ms = 4.0
fs = 12.0
fn = 'Times New Roman'

# # x=y/b0; y1=u/V_J; y2=y3=p/0.5*rho*gh
# y1 = np.linspace(0, 1.0, 100)
# x = 2/np.pi * (np.arctan(y1) + np.arctanh(y1))
# y2 = np.exp(-np.pi * x**2 / 4)
# y3 = 1 - y1**2

# plt.figure(1)
# plt.plot(x, y1, 'k-', label='$y/b_0$')
# plt.plot(x, y2, 'r--', label='$u/V_J$')
# plt.plot(x, y3, 'g-', label='$p/(1/2)\\rho V_J^2$')
# plt.xlabel('$y/b_0$', fontsize=fs)
# plt.ylabel('$u/V_J$ and $p/(1/2)\\rho V_J^2$', fontsize=fs)
# plt.xlim([0, 1.6])
# plt.ylim([0, 1.0])
# plt.xticks(np.arange(0, 1.8, 0.2), labels=['%2.1f' % i for i in np.arange(0, 1.8, 0.2)])
# plt.yticks(np.arange(0, 1.2, 0.2), labels=['%2.1f' % i for i in np.arange(0, 1.2, 0.2)])
# plt.gca().invert_yaxis()
# # plt.legend(loc='upper right')
# plt.box(on=True)
# plt.show()

# x=r/b0; y=p/0.5*rho*gh
x = np.linspace(0, 1.6, 100)
y = np.exp(-2 * x**2)

plt.figure(2)
plt.plot(x, y, 'k-')
plt.xlabel('$r/b_0$', fontsize=fs)
plt.ylabel('$p/(1/2)\\rho V_J^2$', fontsize=fs)
plt.xlim([0, 1.6])
plt.ylim([0, 1.0])
plt.xticks(np.arange(0, 1.8, 0.2), labels=['%2.1f' % i for i in np.arange(0, 1.8, 0.2)])
plt.yticks(np.arange(0, 1.2, 0.2), labels=['%2.1f' % i for i in np.arange(0, 1.2, 0.2)])
plt.gca().invert_yaxis()
plt.show()

python代码 y轴反向输出_第1张图片

你可能感兴趣的:(python代码,python)