QMplRenderer

class QMplRenderer(design: QDesign, *, canvas: PlotCanvas | None = None, logger: Logger | None = None)[source]

Matplotlib renderer for Metal designs.

Can be used in two ways:

  1. Standalone (no Qt): QMplRenderer(design) — produces a renderer that plots into any matplotlib Axes passed to render(). This is the path used by qiskit_metal.view() and by tutorials that want to display a design inline in a Jupyter notebook with no GUI.

  2. Inside the Qt MetalGUI: QMplRenderer(design, canvas=plot_canvas) — the desktop GUI’s PlotCanvas instantiates this way to wire the renderer to its embedded matplotlib figure. The canvas argument is stored on self.canvas for callers that need it, but no method in this class uses it directly.

The ax to render into is still passed explicitly to render() — neither construction path implies a fixed axes.

Parameters:
  • design – The design to render. Required.

  • canvas – Optional Qt PlotCanvas (legacy path used by MetalGUI). Pass None for a standalone / headless renderer.

  • logger – Optional logger. Falls back to a module-level logger if None.

Attributes

qgeometry

Return the qgeometry of the design.

styles = {'JJ': {'base': {'alpha': 0.2, 'edgecolors': 'k', 'linewidth': 1}, 'non-subtracted': {}, 'subtracted': {'color': 'gray', 'linestyle': '--'}}, 'path': {'base': {'alpha': 0.5, 'linewidth': 2}, 'non-subtracted': {}, 'subtracted': {}}, 'poly': {'base': {'alpha': 0.5, 'edgecolors': 'k', 'linewidth': 1}, 'non-subtracted': {}, 'subtracted': {'color': 'gray', 'linestyle': '--'}}}

Styles

Methods

clear_options()[source]

Clear all options.

fillet_path(row)[source]

Output the filleted path. :param row: Row to fillet. :type row: DataFrame

Returns:

Polygon of the new filleted path.

get_color_num(num: int) str[source]

Get the color from the given number. :param num: number :type num: int

Returns:

color

Return type:

str

get_mask(table: DataFrame) Series[source]

Gets the mask. :param table: dataframe :type table: pd.DataFrame

Returns:

return pandas index series with boolen mask - i.e., which are not hidden or otherwise

Return type:

pd.Series

get_style(element_type: str, subtracted=False, layer=None, extra=None)[source]

Get the style. :param element_type: The type of element. :type element_type: str :param subtracted: True to subtract the key. Defaults to False. :type subtracted: bool :param layer: The layer. Defaults to None. :type layer: layer :param extra: Extra stuff to add. Defaults to None. :type extra: dict

Returns:

Style dictionary

Return type:

dict

hide_component(name)[source]

Hide the component with the given name. :param name: Component name :type name: str

hide_layer(name)[source]

Hide the layer with the given name. :param name: Layer name :type name: str

render(ax: Axes)[source]

Assumes that the axis has been cleared already and so on. :param ax: mpl axis to draw on :type ax: matplotlib.axes.Axes

render_fillet(table)[source]

Renders fillet path. :param table: Table of elements with fillets :type table: DataFrame

Returns:

DataFrame table with geometry field updated with a polygon filleted path.

render_junction(table: DataFrame, ax: Axes, subtracted: bool = False, extra_kw: dict | None = None)[source]

Render a table of junction geometry. A junction is basically drawn like a path with finite width and no fillet. :param table: Element table :type table: DataFrame :param ax: Axis to render on :type ax: matplotlib.axes.Axes :param extra_kw: Style params :type extra_kw: dict

render_path(table: DataFrame, ax: Axes, subtracted: bool = False, extra_kw: dict | None = None)[source]

Render a table of path geometry. :param table: Element table :type table: DataFrame :param ax: Axis to render on :type ax: matplotlib.axes.Axes :param kw: Style params :type kw: dict

render_poly(table: DataFrame, ax: Axes, subtracted: bool = False, extra_kw: dict | None = None)[source]

Render a table of poly geometry. :param table: Element table :type table: DataFrame :param ax: Axis to render on :type ax: matplotlib.axes.Axes :param kw: Style params :type kw: dict

render_tables(ax: Axes)[source]

Render the tables. :param ax: The axes :type ax: Axes

set_design(design: QDesign)[source]

Set the design. :param design: The design :type design: QDesign

show_component(name)[source]

Show the component with the given name. :param name: Component name :type name: str

show_layer(name)[source]

Show the layer with the given name. :param name: Layer name :type name: str