plot_spectrum_datasets_off_regions¶
-
gammapy.visualization.
plot_spectrum_datasets_off_regions
(datasets, ax=None, legend=None, legend_kwargs=None, **kwargs)[source]¶ Plot the off regions of spectrum datasets.
- Parameters
- datasets
Datasets
of or sequence ofSpectrumDatasetOnOff
List of spectrum on-off datasets.
- ax
WCSAxes
Axes object to plot on.
- legendbool
Whether to add/display the labels of the off regions in a legend. By default True if
len(datasets) <= 10
.- legend_kwargsdict
Keyword arguments used in
matplotlib.axes.Axes.legend
. Thehandler_map
cannot be overridden.- **kwargsdict
Keyword arguments used in
gammapy.maps.RegionNDMap.plot_region
. Can contain aCycler
in aprop_cycle
argument.
- datasets
Notes
Properties from the
prop_cycle
have maximum priority, exceptcolor
,edgecolor
/color
is selected from the sources below in this order:kwargs["edgecolor"]
,kwargs["prop_cycle"]
,matplotlib.rcParams["axes.prop_cycle"]
matplotlib.rcParams["patch.edgecolor"]
,matplotlib.rcParams["patch.facecolor"]
is never used.Examples
Plot forcibly without legend and with thick circles:
plot_spectrum_datasets_off_regions(datasets, ax, legend=False, linewidth=2.5)
Plot that quantifies the overlap of off regions:
plot_spectrum_datasets_off_regions(datasets, ax, alpha=0.3, facecolor='black')
Plot that cycles through colors (
edgecolor
) and line styles together:plot_spectrum_datasets_off_regions(datasets, ax, prop_cycle=plt.cycler(color=list('rgb'), ls=['--', '-', ':']))
Plot that uses a modified
rcParams
, has two legend columns, static and dynamic colors, but only shows labels fordatasets1
anddatasets2
. Note thatlegend_kwargs
only applies if it’s given in the last function call withlegend=True
:plt.rc('legend', columnspacing=1, fontsize=9) plot_spectrum_datasets_off_regions(datasets1, ax, legend=True, edgecolor='cyan') plot_spectrum_datasets_off_regions(datasets2, ax, legend=True, legend_kwargs=dict(ncol=2)) plot_spectrum_datasets_off_regions(datasets3, ax, legend=False, edgecolor='magenta')