Figure Composer¶
Figure Composer is a GUI for building publication-quality Matplotlib figures from ImageTool data, without needing to write or edit code. It is designed for the common workflow where you explore data interactively, then turn the useful view into a reproducible figure without rewriting the whole plot in a notebook.
The composer stores a figure as a recipe: a layout of axes plus an ordered list of steps that each correspond to a plotting operation.
For creating a figure and managing sources, see Creating and exporting a reusable figure. For complete Python and Figure Composer examples, see the plotting gallery.
Sources¶
Figure Composer can start with or without data sources. In ImageTool Manager, creates a figure without sources or recipe steps. Use Add… in the Sources tab, or drag ImageTool rows from the Manager, to add sources later.
The Sources tab lists the named data variables stored with the figure. Use Refresh to update selected sources from their ImageTools. Use Reveal in Manager to select their ImageTool rows and bring the Manager to the front.
The Add to Figure… action in ImageTool Manager can create a figure, add a plotting step, add a source without changing the recipe, or replace a source. See Reusing a figure recipe with other data for the replacement procedure.
Layout¶
The Layout tab controls the global figure structure. You can define the size and DPI of the figure, and the number of axes and their arrangement.
Use Subplots mode for regular grids created with
matplotlib.pyplot.subplots().Use GridSpec mode for more complex figures that include axes that span several cells or nested regions created with
matplotlib.gridspec.GridSpec. Drag in the GridSpec editor to create rectangular axes or nested grids. Open a nested grid to edit it in place, then use the breadcrumb controls to return to the parent grid. Select an axes region, then use the x or y control under Share axes to select the axes that share that coordinate axis.
Recipe steps¶
The Recipe tab contains a list of steps that generate the figure content. Each step is an interface to a function or method call that modifies the figure. The step list is ordered, and the generated code runs in that order, so steps can depend on the figure state created by earlier steps.
Every step has a type, a target (axes or figure), and a set of controls for the arguments of the plotting or styling calls it generates.
The step table shows each operation, its target, and its current status. For steps that act on axes, the Target column highlights the affected axes in a miniature of the current subplot or GridSpec layout. The Status reports missing sources, invalid targets or inputs, and rendering errors when they occur. Hover over a reported problem for details.
There are several step types:
Set Palette to set the line color cycle with a named palette, custom colors, or a generated seaborn cubehelix, diverging, light, or dark palette.
Image Plot for one two-dimensional image on one axes. Uses
erlab.plotting.plot_array().Slice Plot for plotting multiple slices on multiple axes. Uses
erlab.plotting.plot_slices().Line/Profile for extracted one-dimensional profiles. This also provides an ability to create MDC/EDC stack plots. You can either use this step as a simple interface to
xarray.DataArray.plot()with 1D data, or use it to extract multiple profiles from higher dimensional data.BZ Overlay for in-plane and out-of-plane Brillouin-zone slice overlays drawn with
erlab.plotting.plot_in_plane_bz()anderlab.plotting.plot_out_of_plane_bz().Photon Energy Overlay for annotating constant photon energies on \(k_\parallel\)-\(k_z\) plots using
xarray.DataArray.kspace.hv_to_kz().ERLab Method for a subset of
erlab.plottingfunctions such as colorbar and annotation utilities. This includeserlab.plotting.plot_core_levels()for expected core-level energies.Axes Method for a subset of Matplotlib
ax.*methods.Figure Method for a subset of Matplotlib
fig.*methods.Python for arbitrary code snippets.
Editing steps¶
Selecting a step opens its controls, which vary based on the step type. Each control is an interface to an argument passed onto the underlying function or method.
Tip
Most controls have a tooltip that appears when you hover over them. Some steps have a button that leads to the relevant documentation webpage for the underlying function or method.
Use the checkbox beside a step to enable or disable it. Steps can be cut, copied, pasted, or removed from the toolbar. Reorder steps by dragging their rows. Use the right-click context menu to duplicate steps or move them.
By selecting multiple steps, you can edit them simultaneously to apply the same change to all selected steps. Copied or cut steps can be pasted into another Figure Composer.
When the source and destination composers are open in the same app process, pasted steps also bring the data sources they use.
Toolbar controls¶
Use the toolbar in the figure window to change the plot. The subplot configuration button edits subplot spacing and the layout engine. The axes customization button edits the selected axes.
For preserving a figure recipe, see Preserving the figure recipe.
For export procedures, see Exporting the figure.
Styles and export settings¶
Figure Composer applies the Matplotlib stylesheets selected in the shared Settings window. These styles control new figure defaults and the appearance of figure elements. An enabled Override stylesheet setting takes precedence over the stylesheet value for the corresponding option.
The Export tab controls DPI, transparency, bounding box, and padding for one figure. Use Defaults inherits the current workspace or user setting.
Custom *.mplstyle files are discovered from the Figure Composer stylesheet folder.
Saved style names remain in settings when their files are unavailable. Missing styles
are skipped during rendering and code generation, then become active again after the
file is restored and the style list is reloaded.