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.
Opening Figure Composer¶
There are three main entry points:
From ImageTool, right-click an image or line plot and choose New Figure. This creates a new figure seeded from the selected image.
If multiple cursors exist, a figure with multiple axes is created. This is useful for quickly generating comparison figures with several slices of the same data.
From ImageTool, choose Append to Figure from the same context menu to add the current plot to an existing figure.
From the manager, select one or more ImageTool rows and click Figure in the right-click context menu of the selection. You can choose to create a new figure or append to an existing one.
Figures are listed in the manager’s Figures tab, which is hidden until a figure is created.
A Figure Composer is comprised of two main windows: the window that contains all the controls, and the Matplotlib figure window that shows the rendered figure.
Layout¶
In the controls window of the Figure Composer, the layout shows tabs for the global figure structure and the recipe steps.
The Layout tab controls the global figure structure, where 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(). Set rows, columns, shared x/y axes, layout engine,
and optional width or height ratios. This is the quickest way to create a row of
constant-energy maps or a stacked image/profile figure.
Use GridSpec mode when the figure needs 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. Axis labels are
optional; the composer generates stable names for code when labels are left blank.
Changing the layout does not silently rewrite step targets. If a step points to axes that no longer exist, the step remains editable and is marked invalid until you repair the target axes.
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.
There are several step types, each with a different set of controls for the generated code:
Plot Slices as an interface to
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.ERLab Method for a subset of
erlab.plottingfunctions such as colorbar and annotation utilities.Axes Method for a subset of Matplotlib
ax.*methods.Figure Method for a subset of Matplotlib
fig.*methods.Custom Code for arbitrary code snippets.
Toolbar controls¶
In addition to the recipe controls, plots can also be customized with the toolbar of the figure window. You can edit the subplot spacing and edit various figure elements from dialogs opened from the toolbar buttons.
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.
Steps can be enabled, disabled, duplicated, reordered, or removed. By selecting multiple steps, you can edit them simultaneously to apply the same change to all selected steps.
Reproducibility¶
Figure recipes are saved in ImageTool Manager workspace files, so they are portable and can be shared with collaborators.
Removing a source ImageTool does not delete figures that reference it; the figure is kept and the source is marked missing until it can be restored or replaced.
Use Copy Code in the composer for recipe code that assumes the figure sources already exist as Python variables.
Use the manager side panel’s Copy Full Code action when you want recursive replay code that includes all analysis steps.
Stylesheets and export¶
Figure Composer applies the Matplotlib stylesheets configured in the interactive settings dialog in File → Settings. These stylesheets affect new figure defaults such as size, dpi, and export settings, as well as the styling of all figure elements. If a saved stylesheet is unavailable on the current computer, it remains visible in settings but is skipped when rendering or generating code.