python - 是否可以检测 matplotlib 艺术家是否适合与 colorbar 一起使用?

标签 python matplotlib

一些 matplotlib 函数(例如,contourfimshow)返回艺术家对象,当作为 mappable 参数传递时,这些对象可用于生成颜色条至 colorbars .其他对象(例如,plot)返回不可映射的艺术家。

是否有可能检测出艺术家是否是这样一个合适的对象?我想编写一个使用任意 pyplot 函数的 API,并让我在事后根据返回 mappable 的最后一个函数添加一个颜色条。

最佳答案

这是我过去使用的 hack:

hasattr(cs, 'autoscale_None')

但不确定这是否适用于所有艺术家。通常可以区分颜色条 Material 可映射对象(countour(f)、pcolor、scatter 等)之外的线和点。

关于python - 是否可以检测 matplotlib 艺术家是否适合与 colorbar 一起使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33023036/

相关文章:

python-2.7 - 使用循环绘制 n 个图表 Python

python - 如何防止 matplotlib 窃取焦点?

python - 了解 Pandas SettingWithCopyWarning

python - 如何计算每个月或某个月份的事件日期

python - 如何在xbmc附加组件上使用settings.xml?

python - 在 matplotlib 中制作移动平均时间序列线图的任何解决方法?

python - 将 Pandas DataFrame 中的列类型更改为 int64

python - 生命计数器不断重置

matplotlib - 在 jupyter qtconsole 中自动运行 %matplotlib inline

python - 难以在具有对数刻度的散点图上绘制线性回归线