From f2ef5373b09da255087a34c34f1043c6a69330f7 Mon Sep 17 00:00:00 2001 From: Michal Sojka Date: Tue, 30 Mar 2021 19:21:50 +0200 Subject: [PATCH 1/2] Show plots in internal VS Code plot pane With this change, when Gnuplot.jl is used within VSCode, the plot shows in VSCode plot pane instead of in a separate Gnuplot window. Note that when compared to IJulia and Juno, we do not test for active VS Code connection. I don't think it is necessary, but if it turns out to be needed later, it can be done with isopen(VSCodeServer.conn_endpoint[]) --- README.md | 2 +- src/Gnuplot.jl | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fb01169..c184a68 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![DocumentationStatus](https://img.shields.io/badge/docs-stable-blue.svg?style=flat)](https://gcalderone.github.io/Gnuplot.jl/v1.3.0/) -**Gnuplot.jl** is a simple package able to send both data and commands from Julia to an underlying [gnuplot](http://gnuplot.sourceforge.net/) process. Its main purpose it to provide a fast and powerful data visualization framework, using an extremely concise Julia syntax. It also has automatic display of plots in both Jupyter and Juno. +**Gnuplot.jl** is a simple package able to send both data and commands from Julia to an underlying [gnuplot](http://gnuplot.sourceforge.net/) process. Its main purpose it to provide a fast and powerful data visualization framework, using an extremely concise Julia syntax. It also has automatic display of plots in Jupyter, Juno and VS Code. ## Installation diff --git a/src/Gnuplot.jl b/src/Gnuplot.jl index 8650d59..5c3d9fb 100644 --- a/src/Gnuplot.jl +++ b/src/Gnuplot.jl @@ -236,11 +236,12 @@ const sessions = OrderedDict{Symbol, Session}() const options = Options() function __init__() - # Check whether we are running in an IJulia, Juno or Pluto session. + # Check whether we are running in an IJulia, Juno, VSCode or Pluto session. # (copied from Gaston.jl). options.gpviewer = !( ((isdefined(Main, :IJulia) && Main.IJulia.inited) || (isdefined(Main, :Juno) && Main.Juno.isactive()) || + (isdefined(Main, :VSCodeServer)) || (isdefined(Main, :PlutoRunner)) ) ) end From 34af493921da46558b84c020c9365a95b7f7b2a7 Mon Sep 17 00:00:00 2001 From: Michal Sojka Date: Tue, 30 Mar 2021 20:11:05 +0200 Subject: [PATCH 2/2] Make the figures in VS Code bigger Without this change, the figures in VS Code are too small. --- src/Gnuplot.jl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Gnuplot.jl b/src/Gnuplot.jl index 5c3d9fb..e1fd16e 100644 --- a/src/Gnuplot.jl +++ b/src/Gnuplot.jl @@ -244,6 +244,10 @@ function __init__() (isdefined(Main, :VSCodeServer)) || (isdefined(Main, :PlutoRunner)) ) ) + if isdefined(Main, :VSCodeServer) + # VS Code shows "dynamic" plots with fixed and small size :-( + options.mime[MIME"image/svg+xml"] = replace(options.mime[MIME"image/svg+xml"], "dynamic" => "") + end end