首先,在这被标记为复制之前,我已经阅读了其他解决方案,不幸的是,它们都不适合我.

我的问题是,我想在Juypter Notebook(并且只在Jupyter Notebook)中显示bokeh绘图,而不是在新的选项卡/窗口中.

在官方文件here中,我被告知我只需要改变

output_file

output_notebook

Even though the plot is now displayed inline if I do that, bokeh won't s到p also opening a new tab and needlessly displaying the plot there.

Since I'm gonna create lots of plots in my project, it'd be very nice 到 not always have 到 close this new tab and return 到 notebook, but just have it s到p creating new tabs, just as it would work with e.g. matplotlib.

What confuses me is that if I load up the official tu到rial and enter code there, for example

import numpy as np

x = np.linspace(0, 10, 100)
y = np.exp(x)

p = figure()
p.line(x, y)

show(p)

没有打开新选项卡.如果我现在在我机器的Juypter笔记本上本地运行相同的代码,它会打开一个新标签.

I've been trying for a while now 到 fix this, any help would be very much appreciated.

先谢谢你,文森特

推荐答案

你需要在笔记本顶部拨打output_notebook,但only拨打output_notebook.如果调用output_file,则会激活一个持久模式,将输出保存到文件中,并使show打开包含这些文件的新选项卡.您需要拨打reset_output以清除持续模式.

为了方便起见,由于有几个用户要求,如果提供了no输出模式,show的行为就好像output_file是默认的一样.没有从Binder教程中打开选项卡的原因是,从技术上讲,在Binder服务器上远程运行的代码不可能在本地浏览器上打开选项卡(这是一件非常好的事情).

Python-3.x相关问答推荐

海象表达可以放在方括号中而不是括号中吗?

如何创建一个polars gramme,给出列表中的列名,

如何定义既允许固定单词又允许模式的pydanti.BaseModel?

如何使用Selenium从网站下拉菜单中获取值列表?

将数据框中的值与另一个数据框中的多列进行比较,以获取条目以有效方式匹配的列表列表

以不规则频率识别数据框日期时间列上缺失的日期,并用关联值填充它们

是否可以将多个 if 转换为数组?

使用正则表达式捕获组解析地址

pymongo 失败并出现错误未定义

Pytorch:图像标签

如何从 Python 3.5 降级到 Python 3.4

逗号分隔列表的 argparse 操作或类型

如何模拟 Django 模型对象(及其方法)?

django - 值更改后自动更新日期

如何调试垂死的 Jupyter Python3 内核?

为什么中断比引发异常更快?

如何在 Selenium 和 Python 中使用类型查找元素

警告:请使用 tensorflow/models 中的官方/mnist/dataset.py 等替代方案

哪个更有效:Python 文档字符串还是类型提示?

如何更改 tkinter 文本小部件中某些单词的 colored颜色 ?