在我的简单绘图脚本中加入
plt.yscale('log')
这行代码后,结果发生了变化。import numpy as np
residuals = np.loadtxt('res_jacobi.txt', skiprows=1)
import matplotlib.pyplot as plt
fig = plt.figure()
steps = np.arange(0, len(residuals), 1)
plt.plot(steps, residuals, label='$S$')
plt.xlabel("Step",fontsize=20)
plt.ylabel("$S$",fontsize=20)
plt.ylim(0.95 * min(residuals), 1.05 * max(residuals))
plt.yscale('log')
plt.savefig('jacobi-res.pdf', bbox_inches='tight', transparent=True)
Y轴标签消失了。
我确定这个问题有一个简单的解决方法,但是搜索并没有找到结果。任何帮助将不胜感激。
semilogy
函数。http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.semilogy - David Maust