繁体   English   中英

Matplotlib:如何在现有颜色条上添加标签?

[英]Matplotlib: How to add a label to existing colorbar?

我正在使用一个名为kwant的Python模块,它自动为我创建一个完整的图,包括一个颜色条。 但是,我没有找到任何方法为此颜色栏添加标签。 由于我无法访问直接构建绘图的数据,因此我只能希望能够从已创建的图形对象中访问colorbar对象。 有没有可能这样做?

https://kwant-project.org/doc/1/reference/generated/kwant.plotter.plot

colorbar : bool
Whether to show a colorbar if colormap is used. Ignored if ax is provided.

https://kwant-project.org/doc/1.0/reference/kwant.plotter

你看过这个吗?

我没有这个模块的经验,但是......从文档中 ,绘图函数将来自matplotlib的ax作为输入。 所以你可以做点什么

import matplotlib.pyplot as plt
fig, ax = plt.subplots(1) 
...
out = kwant.some_plot(..., ax = ax)

现在,您可以使用matplotlib通过fig和ax访问绘图的不同部分。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM