您可以在 Python 中的单个图形窗口中循环浏览多个绘图吗?



我试图弄清楚如何在一个图中绘制多个图,但不使用子图也不在同一轴上。从本质上讲,我想做的是,例如,有单独的sinecosinetangent的情节。它们都将位于同一个图形窗口中,您可以使用箭头键在不同的绘图之间切换。我想象它需要将它们存储在列表或数组中。

如果这里其他地方有人问过这个问题,请指出我这个方向,我将关闭这个问题。

感谢您的任何帮助!

如评论部分所示,您可以使用散景。完全受散景文档的启发,实现方式可能如下:

from bokeh.models.widgets import Panel, Tabs
from numpy import pi, arange, sin, cos
from bokeh.plotting import output_file, figure, show
output_file("slider.html")
x = arange(-2*pi, 2*pi, 0.1)
# your different functions
y1 = sin(x)
y2 = cos(x)
# building a tab per function/plot
p1 = figure(plot_width=300, plot_height=300)
p1.circle(x, y1, color="red")
tab1 = Panel(child=p1, title="sinus")
p2 = figure(plot_width=300, plot_height=300)
p2.circle(x, y2, color="blue")
tab2 = Panel(child=p2, title="cosinus")
# aggregating and plotting
tabs = Tabs(tabs=[tab1, tab2])
show(tabs)

最新更新