【问题标题】:How to get Julia Makie Output in python Jupiter notebook?如何在 python Jupyter notebook 中获取 Julia Makie 输出?
【发布时间】:2022-08-23 15:03:28
【问题描述】:

运行以下笔记本单元

%load_ext julia.magic
%%julia
using GLMakie 

function plot_something()
    odeSol(x,y) = Point(-x, 2y)             # x\'(t) = -x, y\'(t) = 2y
    fig = Figure(resolution =(400,400))
    ax = Axis(fig)
    streamplot!(ax, odeSol, -2..2, -2..2, colormap = :plasma, 
        gridsize= (32,32), arrow_size = 0.07)
    fig[1,1] = ax
    fig
end
from julia import Main
Main.show_something()

产生 `<PyCall.jlwrap Scene (400px, 400px):\' 而不是希望的数字。有什么好的修复吗?

    标签: python julia jupyter makie.jl


    【解决方案1】:

    目前可能的修复

    function makie2image(fig)
        buf = IOBuffer()
        Makie.backend_show(GLMakie.GLBackend(), buf, MIME("image/png"), fig.scene)
        pyimport("IPython").display.Image(pybytes(buf.data))
    end
    

    用作:

    Main.makie2image(Main.plot_something())
    

    【讨论】:

      猜你喜欢
      • 2020-09-03
      • 2020-01-24
      • 1970-01-01
      • 1970-01-01
      • 2018-06-06
      • 2021-05-07
      • 1970-01-01
      • 2018-11-25
      • 1970-01-01
      相关资源
      最近更新 更多