如何向现有颜色栏添加标签

问题描述 投票:0回答:2

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

python matplotlib colorbar
2个回答
2
投票

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

你看过这个吗?


1
投票

我没有这个模块的经验,但是...... 从 docs 中,绘图函数将 matplotlib 中的 ax 作为输入。 所以你可以做类似的事情

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

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

© www.soinside.com 2019 - 2024. All rights reserved.