triqs.plot.protocol.plot_protocol_apply

triqs.plot.protocol.plot_protocol_apply(ob, opt_dict, xlims)[source]

Apply the plot protocol to an arbitrary object.

Dispatches ob to the most specific plot-protocol handler available, in this order:

  1. ob._plot_(opt_dict) if ob exposes a _plot_ method.

  2. plot_function_table[type(ob)](ob, opt_dict) if type(ob) is registered in plot_function_table.

  3. If ob is callable, sample it on a uniform grid of n_points (default 100) points spanning x_window (taken from opt_dict or xlims() as a fallback).

  4. Otherwise, treat ob as an iterable of (x, y) pairs.

Complex-valued ordinates are split into separate real and imaginary curves labelled "Re <name>" and "Im <name>".

Parameters:
obobject

Object to be plotted. Must implement the plot protocol, be registered in plot_function_table, be callable, or be an iterable of (x, y) pairs.

opt_dictdict

Plotting options. Keys consumed here (n_points, x_window, name) are popped; remaining keys are forwarded inside the returned curve dictionaries.

xlimscallable

Zero-argument callable returning (xmin, xmax) for the sampling window when ob is callable and no x_window was given. Typically matplotlib.pyplot.xlim.

Returns:
list of dict

Curve dictionaries as described in the module docstring.

Raises:
RuntimeError

If ob does not match any of the supported forms.