Chart

Chart#

class Chart(NameValueArgs)#

Bases: handle

Chart utility to create, position, show, and save figures.

Manages figure creation across multiple monitors, supports logical positioning and sizing (fractions or presets), and saving to .fig /.png or opening a .gif instead when IsGif is true.

Examples:

ch = Chart(name="Spectrum", num=2, fpath="C:/tmp/spectrum", ...
           loc=[0.05,0.1], size=[0.5,0.4], isGif=false);
fig = ch.initialize();
plot(rand(100,1)); drawnow;
ch.save();
ch.close();
Constructor Summary
Chart(NameValueArgs)#

Construct a Chart from name-value arguments.

Parameters:
  • name (string) – Figure window title

  • num (double) – Figure number/ID

  • fpath (string) – Save/load path without extension

  • loc (string or double) – Location preset string or [xFrac,yFrac] in (0,1)

  • size (string or double) – Size preset string or [wFrac,hFrac] in (0,1)

  • isGif (logical optional) – Treat target as GIF for showGif()

  • isEnabled (logical optional) – If false, all operations are no-ops

Property Summary
Figure#

Handle to the managed figure (created in initialize())

IsEnabled logical = true#

Master switch to disable all operations

IsGif logical = false#

If true, treat target as GIF and open it via showGif()

Location#

Logical location [xFrac,yFrac] or preset string (e.g. “eastnorthwest”)

Monitor double = 1#

Target monitor index (1 is primary)

Name string#

Human-readable figure name (window title)

Number double#

Figure number/ID (used for reuse)

Path string#

File path without extension for saving/reading

Size#

Logical size [wFrac,hFrac] or preset string: “small”,”medium”,”large”,”largetall”,”full”

Method Summary
close()#

Close the managed figure window if it exists.

initialize()#

Create or reuse the figure, position and size it, and return its handle.

Uses monitor geometry from sortMonitor and supports both preset strings and fractional coordinates/sizes in (0,1).

Returns:

fig — Figure handle; if IsEnabled is false returns {1}.

Return type:

matlab.ui.Figure or cell

save()#

Save figure to .fig (if size is reasonable) and .png.

Checks existence and image data size to avoid extremely large .fig files, then writes PNG unconditionally.

show()#

Show a previously saved .fig in a managed figure window.

Creates the window via initialize() and clones the saved content using copyobj if the figure file exists.

showGif()#

Open the target .gif in the system viewer when IsGif is true.