matplotlib - 你能提取 Matplotlib 对数轴中使用的对数的底吗?
问题描述
如果有人创建了 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
值是什么?我可以得到xscale
with ax.get_xscale()
,但没有等价物ax.get_basex()
。
解决方案
由于get_scale
返回name
实际使用的matplotlib.scale.LogScale
对象的字段ax.get_xaxis()._scale
而不是对象本身,不幸的是我没有找到另一种方法,然后直接访问base
私有字段_scale
。不鼓励访问私有字段,但是
ax.get_xaxis()._scale.base
给你结果。
推荐阅读
- android - Android aar包含jar依赖资源文件夹
- python - 如何将 dict_keys 转换为整数
- c# - WPF DataGrid Combobox binding to data on load with separate ItemsSource
- c - 分配/重新分配内存的内存泄漏,“1 个块中的 5 个字节肯定丢失”
- mysql - Transposing groups of rows with the same ID into another table
- javascript - retrieve data from a collection in meteor
- python-3.x - 如何在 ImageDataGenerator 增强中增强多个图像?
- css - Is it possible to animate a non-SVG image on UI?
- symfony - How to use SASS with Symfony 4?
- asp.net - 如何使用 ASP.NET 获取数据属性?