你能提取 Matplotlib 对数轴中使用的对数的底数吗?
Can you extract the base of the logarithm used in a Matplotlib logarithimic axis?
如果有人创建了 Matplotlib 图,例如,
from matplotlib import pyplot as plt
import numpy as np
plt.plot([1, 2, 3, 4], [1, 2, 3, 4])
ax = plt.gca()
ax.set_xscale('log', basex=np.e)
有没有办法从轴中提取 basex
值?我可以用 ax.get_xscale()
得到 xscale
,但是没有等效的 ax.get_basex()
。
由于get_scale
return实际使用matplotlib.scale.LogScale
对象的name
字段ax.get_xaxis()._scale
而不是对象本身,很遗憾没有找到另一个然后直接访问私有字段 _scale
的 base
。不鼓励访问私有字段,但是
ax.get_xaxis()._scale.base
给你结果。
如果有人创建了 Matplotlib 图,例如,
from matplotlib import pyplot as plt
import numpy as np
plt.plot([1, 2, 3, 4], [1, 2, 3, 4])
ax = plt.gca()
ax.set_xscale('log', basex=np.e)
有没有办法从轴中提取 basex
值?我可以用 ax.get_xscale()
得到 xscale
,但是没有等效的 ax.get_basex()
。
由于get_scale
return实际使用matplotlib.scale.LogScale
对象的name
字段ax.get_xaxis()._scale
而不是对象本身,很遗憾没有找到另一个然后直接访问私有字段 _scale
的 base
。不鼓励访问私有字段,但是
ax.get_xaxis()._scale.base
给你结果。