Chart#
- class Chart(NameValueArgs)#
Bases:
handleChartutility 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/.pngor opening a.gifinstead whenIsGifis 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
Chartfrom name-value arguments.- Parameters:
name (
string) – Figure window titlenum (
double) – Figure number/IDfpath (
string) – Save/load path without extensionloc (
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 forshowGif()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
- 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
sortMonitorand supports both preset strings and fractional coordinates/sizes in (0,1).- Returns:
fig — Figure handle; if
IsEnabledis 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
.figfiles, then writes PNG unconditionally.
- show()#
Show a previously saved
.figin a managed figure window.Creates the window via
initialize()and clones the saved content usingcopyobjif the figure file exists.