-
Notifications
You must be signed in to change notification settings - Fork 16
Switch to using display() to show the plots #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
@pfitzseb Do you know why # Copied from Plots - insert GnuplotDisplay before text displays, but after graphic displays such as IJulia, VSCodeDisplay, etc.
insert!(Base.Multimedia.displays, findlast(x -> x isa Base.TextDisplay || x isa REPL.REPLDisplay, Base.Multimedia.displays) + 1, GnuplotDisplay())
atreplinit(i -> begin
while GnuplotDisplay() in Base.Multimedia.displays
popdisplay(GnuplotDisplay())
end
insert!(Base.Multimedia.displays, findlast(x -> x isa REPL.REPLDisplay, Base.Multimedia.displays) + 1, GnuplotDisplay())
end) It seems it's not necessary. In my tests, plain |
This brings better compatibility with the Julia package ecosystem. Now, if Gnuplot.jl is used in an environment capable of showing multimedia content (IJulia, VS Code, Pluto), their internal viewer will take precedence over using gnuplot's built-in viewer. In the REPL, gnuplot viewer is still used by default. In VS Code, for example, when the *Use Plot Pane* settings is enabled, the plots show in that pane, but when it is disabled, gnuplot viewer is automatically used. For people who prefer to always use the gnuplot viewer, they can set Gnuplot.options.gpviewer to true. This should result in the same behaviour as before this commit.
I was able to see the difference only in |
@gcalderone Can you try/review this? I tried hard not to break any functionality of |
I see that @gcalderone is working on Gnuplot.jl now, so I'm posting a comment about my experience with using this change for several months. Having However, when I want to use packages like Weave.jl, having So my conclusion is that this change allows me to use Weave.jl, but it's not perfect. Ideally, we'd need a better way than a global variable to distinguish when to send the plot to Julia's Multimedia I/O and when to Gnuplot. One idea, that comes to my mind (inspired by #51), is to check whether stdout is a terminal and decide based on that. If we're lucky packages like Weave.jl will run the code with stdout redirected to a pipe and we could use this as a sign to use Multimedia I/O. On the other hand, it will likely cause other problems in non-standard use-cases. So I'm not really sure what's the best. |
Hi @wentasah , thank you very much for providing such valuable insights on the interplay between the However, as already discussed in #45, the best usage of Gnuplot.jl is (IMHO) outside tools like Jupyter, Juno, Weave, and the like, and therefore I would like to avoid introducing special cases or workarounds which are not thoroughly tested and coherent with the aim of the package. As a specific example, I would really like to avoid having I'm afraid the desire to make Gnuplot.jl works seamlessly in such tools/IDEs may lead to inconsistencies with its original use case, namely the use through the gnuplot external viewer. As anticipated in #45,I would really love to see those functionalities moved in an external package, and I encourage anyone willing to do so. Besides, I have definitely limited experience with Jupyter, Juno, etc., and zero experience with Weave, making it very difficult for me to foresee all the consequences of a choice. For the moment I will leave this PR open, in the hope that it could be used as a starting point for a discussion leading to new packages being developed which allow to use the Gnuplot.jl syntax in all the available (and amazing!) environments. If I understand correctly it all amounts to define the proper I will be more than happy to modify the Gnuplot.jl source code to facilitate this changes, and make it usable / compatible with the new package. |
This brings better compatibility with the Julia package ecosystem. Now, if Gnuplot.jl is used in an environment capable of showing multimedia content (IJulia, VS Code, Pluto), their internal viewer will take precedence over using gnuplot's built-in viewer. In the REPL, gnuplot viewer is still used by default.
In VS Code, for example, when the Use Plot Pane settings is enabled, the plots show in that pane, but when it is disabled, gnuplot viewer is automatically used.
For people who prefer to always use the gnuplot viewer, they can set Gnuplot.options.gpviewer to true. This should result in the same behaviour as before this commit.
Things done:
gpviewer = false
)Summary
The table below is copied from display.ipynb and updated. Only the
false
/REPL column needed to be changed. The values are almost the same as intrue
/REPL, the difference is in Calls to display() / automatic display (trailing ;) and The top level code works also within a function?.Gnuplot.options.gpviewer = true
display()
/ automatic display (trailing;
)display()
calls are not requiredGnuplot.options.term
Gnuplot.options.gpviewer = false
display()
/ automatic display (trailing;
)display()
calls are are requireddisplay()
calls are requireddisplay()
calls are are requiredGnuplot.options.term
Gnuplot.options.mime
Gnuplot.options.mime
Related to #45