【发布时间】:2016-03-18 05:55:28
【问题描述】:
我在 ipython 中有一个程序,它有两个下拉菜单和一个按钮。当我点击按钮时,我想使用下拉列表中的信息搜索数据框,然后并排创建两个直方图。我已经测试了从数据框中检索信息的代码,这工作正常,我可以制作我需要的新直方图。我要做的是从下拉列表中做出新的选择,以便用新的直方图更新旧直方图。目前,它们只是出现在之前的下方。
我该怎么做?
Tldr:如何使用新信息更新现有图表?
编辑:下面是我的代码摘要
fig = plt.figure(figsize=(10,10))
ax1 = fig.add_subplot(121)
ax2 = fig.add_subplot(122)
# Function to find results
def search(btn):
plt.clf()
ax1.hist(results_df1.COLUMNA.dropna().values, bins=180/5, range=(-60,120))
ax2.hist(results_df4.COLUMNA.dropna().values, bins=180/5, range=(-60,120))
plt.show(fig)
# Button to enter information
btn = widgets.Button(description="Update")
btn.on_click(search)
display(btn)
【问题讨论】:
-
你能发布你有什么代码吗?如果不看到现有的东西,就不可能增强。
-
没问题 - 添加了我拥有的代码的摘要:)
标签: python pandas matplotlib ipython histogram