【发布时间】:2015-11-21 18:32:53
【问题描述】:
将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 标签消失。
我确信有一个简单的解决方法,但搜索没有出现。任何帮助将不胜感激。
【问题讨论】:
-
似乎是一个错误,但您可以尝试使用
semilogymatplotlib.org/api/pyplot_api.html#matplotlib.pyplot.semilogy -
@DavidMaust 我不认为这是一个错误,在对数缩放中,仅标记了数量级的主要刻度线。这绝对不是 最佳 行为......但是
标签: python matplotlib axis-labels