【发布时间】:2015-09-29 06:39:26
【问题描述】:
matplotlib 为轴指定对数刻度时,标记该轴的默认方法是使用 10 次方的数字,例如。 10^6。有没有一种简单的方法可以将所有这些标签更改为例如:1、5、10、20?
【问题讨论】:
标签: python matplotlib axis-labels
matplotlib 为轴指定对数刻度时,标记该轴的默认方法是使用 10 次方的数字,例如。 10^6。有没有一种简单的方法可以将所有这些标签更改为例如:1、5、10、20?
【问题讨论】:
标签: python matplotlib axis-labels
发现于this thread
import matplotlib.pyplot as pl
from matplotlib.ticker import ScalarFormatter
fig = pl.figure()
ax = fig.add_subplot(111)
ax.set_xscale('log')
ax.set_xticks([1,2,5,10])
ax.get_xaxis().set_major_formatter(ScalarFormatter())
ax.set_xlim([1., 10.])
【讨论】: