JuliaPlots / JuliaPlots/PlotlyJS.jl

Figure management with unique identifier

Open
#397 2 comments 1 reaction 0 assignees View on GitHub
Dominant language
Julia
Stars
444
Forks
86
PR merge metrics
No merged PRs in 30d

Description

Hi everyone,

Is it possible to open and update Electron figure windows between script executions similarly to the "figure" command in MATLAB?

I am looking for a method similar to the MATLAB's and matplotlib's **figure()** command, so that an internal collection of figures is managed using unique identifiers.

https://se.mathworks.com/help/matlab/ref/figure.html
https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.figure.html

I often have MATLAB figure windows opened in one screen and my script in one screen where execution of the script updates the already opened windows instead of generating new windows.

The closest I have so far is pre-initializing some SyncPlot objects and use them as global variables in my script.

```
# Pre-initialization script, run only once to open the windows
using PlotlyJS, Blink;
figs = [plot(), plot()];
display(figs[1]);
display(figs[2]);
title(figs[1].window, "Figure 1");
title(figs[2].window, "Figure 2");
```

Modifying and executing _plot_script.jl_ many times only updates the windows.

```
# plot_script.jl
using PlotlyJS;

tv = 0:0.0005:0.1;
f = 50;

# Display sine wave in figure 1
addtraces!(figs[1], scatter(x=tv, y=sin.(2*pi*f*tv)));
update!(figs[1]);

# Display cosine wave in figure 2
addtraces!(figs[2], scatter(x=tv, y=cos.(2*pi*f*tv)));
update!(figs[2]);
```

It will be great to know if such built-in method exists or perhaps some nice feature to add to the awesome library.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.