[英]How to draw in a python jupyter notebook?
I ultimately want to be able to draw over the top of other images, and then save the drawing data to be viewed later.我最终希望能够在其他图像的顶部绘制,然后保存绘图数据以供以后查看。
I've tried working with matplotlib.我试过使用 matplotlib。 I got it pretty functional, as described here , but run into a lot of issues since I can't have it open in another window, and when it displays inline, the callback events don't fire properly.
我得到了它的功能,如这里所述,但遇到了很多问题,因为我无法在另一个窗口中打开它,并且当它显示内联时,回调事件不能正确触发。
I'm connecting to a remote jupyter server, so I think everything needs to be inline.我正在连接到远程 jupyter 服务器,所以我认为一切都需要内联。 I've read some stuff about bokeh, and it seems like it might be useful, but I don't know where to start.
我读过一些关于散景的东西,看起来它可能有用,但我不知道从哪里开始。
This seems pretty easy with javascript, but I cant figure out how to get javasctipt to run in jupyter.使用 javascript 这似乎很容易,但我不知道如何让 javasctipt 在 jupyter 中运行。 At least not when its more than just a line or 2.
至少当它不仅仅是一行或 2 行时不会。
I think with bokeh you are already on the right track.我认为散景你已经在正确的轨道上。 For scientific visualization, graphic libraries such as holoviews are quite famous, as they work on a high abstraction level and allow to create interactive diagrams.
对于科学可视化,诸如全息视图之类的图形库非常有名,因为它们在高抽象级别上工作并允许创建交互式图表。 for plotting in an existing plot it would look basically like this:
对于在现有绘图中绘图,它基本上如下所示:
import holoviews as hv
hv.extension('bokeh')
from holoviews import opts
from bokeh.plotting import show, output_file
Curve_opts = {'width':700, 'height':400, 'bgcolor':'#FFFFFF',
'tools':TOOLS, 'line_width':1.2,}
plot = hv.Curve(data=df, kdims=['col_x','col_y'], vdims=['value_in_tag'], label='legend 1')\
* hv.Scatter(data=df, kdims=['col_x','col_y'], vdims=['col_color'], label='legend 2')
# with '*' you plot into the same frame of a layout
plot = plot.relabel("Diagram Title")
plot.opts(opts.Curve(**Curve_opts )) # provide a dict to customize output
hv.save(plot, 'Filename.png', fmt='png') # save as png to be used in an article
output_file('Filename.html') # interactive diagram for web-publishing
show(hv.render(plot)) # workaround as spyder doesn't render hv
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.