Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
939 views
in Technique[技术] by (71.8m points)

gnuplot - Jupyter Octave Kernel Inline Graph Windows

I recently installed the octave_kernel for jupyter notebooks. I also installed gnuplot, but I can't plot inline, this error message shows up:

Inline plot failed, consider trying another graphics toolkit error: print: figure must be visible or qt toolkit must be used with gl_window property 'on' or QT_OFFSCREEN feature available error: called from _make_figures>safe_print at line 125 column 7 _make_figures at line 49 column 13

I think the solution is in the configuration section of this page. However I'm not familiar with jupyter configuration and being on Windows doesn't help... Can you guys help me out?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I think it has to do with how the Octave Kernel connects jupyter to the program, since I get the same error on the newest version of Octave.

Here is what I have discovered:

I have installed two versions of Octave both 32 bits.

  • Octave 4.4.1 that was the one I used the most and
  • Octave 6.1.0 that is the most recent one.

*I also have gnuplot 5.2 patch level 7 installed-

The octave kernel is installed in anaconda via:

conda install octave_kernel

  • to know where to look for the executable in windows you require the enviromental variable, here i tell it to go for Octave-4.4.1:

OCTAVE_EXECUTABLE C:\Octave\Octave-4.4.1\bin\octave-cli.exe

once it's up and running, the jupyter notebook loads the kernel and i run the example:

x=-10:0.1:10+eps;
y=-10:0.1:10+eps;

[xx,yy]=meshgrid(x,y);

zz= sin(sqrt(xx.^2+yy.^2))./(sqrt(xx.^2+yy.^2));

surf(xx,yy,zz)
view(-35,45)
shading interp

resultant plotting from the code above

If I check the graphic toolkits that display the plots with the commands i get:

available_graphics_toolkits()

    ans =
    {
      [1,1] = fltk
      [1,2] = gnuplot
    }

And the current toolkit is:

loaded_graphics_toolkits ()

    ans =
    {
      [1,1] = gnuplot
    }

BUT if i change the enviromental variable to point to the Octave-6.1.0 executable with: C:\Octave\Octave-6.1.0\mingw32\bin\octave-cli.exe

once i run the chunks of code, the ones with calculations are doing fine

x=-10:0.1:10+eps;
y=-10:0.1:10+eps;

[xx,yy]=meshgrid(x,y);

zz= sin(sqrt(xx.^2+yy.^2))./(sqrt(xx.^2+yy.^2));

for example, if i take the ; off the zz variable you get the matrix printed on the output

zz =

 Columns 1 through 6:

   7.0710e-02   7.0912e-02   7.0764e-02   7.0268e-02   6.9428e-02   6.8251e-02
   7.0912e-02   7.0761e-02   7.0254e-02   6.9397e-02   6.8194e-02   6.6655e-02
   7.0764e-02   7.0254e-02   6.9386e-02   6.8166e-02   6.6601e-02   6.4702e-02
   7.0268e-02   6.9397e-02   6.8166e-02   6.6583e-02   6.4658e-02   6.2404e-02
   6.9428e-02   6.8194e-02   6.6601e-02   6.4658e-02   6.2378e-02   5.9773e-02
   6.8251e-02   6.6655e-02   6.4702e-02   6.2404e-02   5.9773e-02   5.6826e-02 ...

 .... etc.

but the plot block of code

surf(xx,yy,zz)
view(-35,45)
shading interp

sends as output the error:

Inline plot failed, consider trying another graphics toolkit
error: print: figure must be visible or qt toolkit must be used with __gl_window__ property 'on' or QT_OFFSCREEN feature available
error: called from
    _make_figures>safe_print at line 125 column 7
    _make_figures at line 49 column 13

Which tells me the jupyter kernel isn't working completely with Octave 6.1.0.

I know Octave 6.1.0 is working because the same code produces the correct plot if you run it directly in the octave application gui or cli.

plot window of the same graph captured from the Octave-gui application


The octave kernel says it's working if I check it with the command

python -m octave_kernel.check

The check reveals:

Octave kernel v0.32.0
metakernel v0.27.5
Python v3.78.56 <default, Sep  4 2020, 00:03:40> [MSC v.1916 32 bit <intel>]
Python path: C:Usersmyuseranaconda3python.exe

Conecting to Octave...
PS C:Usersmyuser> Can't load 'C:Usersmyuseranaconda3libsite-packagesmetakernelmagicsshell_magic.py' : error <pexpect.popen_spawn.PopenSpawn object at 0x033C3178>
searcher: searcher_re:
    0: re.compiler<'>'>
<pexpect.popen_spawn.PopenSpawn object at 0x033C3178>
searcher: searcher_re:
    0: re.compiler<'>'>
Octave conection established
Octave kernel v0.32.0 running GNU Octave v6.1.0
Graphics toolkit: fltk
available toolkits: [1,1] = fltk
    [1,2] = gnuplot
>

when trying to plot in the jupyter notebook the console keeps sending a similar error

PS C:Usersmyuser> [MetaKernelApp] ERROR : Can't load 'C:Usersmyuseranaconda3libsite-packagesmetakernelmagicsshell_magic.py' : error <pexpect.popen_spawn.PopenSpawn object at 0x0341C718>
searcher: searcher_re:
    0: re.compiler<'>'>
<pexpect.popen_spawn.PopenSpawn object at 0x0341C718>
searcher: searcher_re:
    0: re.compiler<'>'>

That seems to be affiliated with accessing the magic.py file in the metakernel package, when plotting.

i think i'm gonna fill an issue at github to see what can be done about this error.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...