Plotting

Classes related to plotting.

API

Classes:

Plotter([config, dpi])

Class to hold plotting routines

Exceptions:

ReorderLOSVDError

class plotter.Plotter(config=None, dpi=100)

Class to hold plotting routines

Class containing methods for plotting results. Each plotting method saves a plot in the outplot/plots directory, and returns a matplotlib figure object.

Parameters:
configa dyn.config_reader.Configuration object
dpifloat, optional

The resolution of saved figures (if not overridden later). The default is 100 dpi.

Methods:

beta_plot([which_chi2, Rmax_arcs, figtype])

Generates anisotropy plots

make_chi2_plot([which_chi2, n_excl, figtype])

Generates a chisquare plot

make_chi2_vs_model_id_plot([which_chi2, figtype])

Generates a chi2 vs.

mass_plot([which_chi2, Rmax_arcs, figtype])

Generates cumulative mass plot

orbit_distribution([model, minr, maxr, nr, ...])

Make the orbit distibution plot

orbit_plot([model, Rmax_arcs, figtype])

Generates an orbit plot for the selected model

plot_kinematic_maps([model, kin_set, ...])

Generates a kinematic map of a model with v, sigma, h3, h4...

qpu_plot([which_chi2, Rmax_arcs, figtype])

Generates triaxiality plot

shiftedColorMap(cmap[, start, midpoint, ...])

Function to offset the "center" of a colormap.

beta_plot(which_chi2=None, Rmax_arcs=None, figtype=None)

Generates anisotropy plots

The two plots show the intrinsic and projected anisotropy (beta_r and beta_z, respectively) as a function of the distance from the galactic centre (in arcsec).

  • beta_r = 1 - (sigma_t/sigma_r)^2

  • beta_z = 1 - (sigma_z/sigma_R)^2

Solid lines and shaded areas represent the mean and standard deviation of the anisotropy of models having parameters in a confidence region around the minimum chisquare.

Currently, this method only works with the LegacyWeightSolver.

Parameters:
which_chi2STR, optional

Which chi2 is used for determining the best models. If None, the setting from the configuration file will be used. The default is None.

Rmax_arcsnumerical value

Determines the upper range of the x-axis.

figtypeSTR, optional

Determines the file extension to use when saving the figure. If None, the default setting is used (‘.png’).

Returns:
fig1matplotlib.pyplot.figure

Figure instance.

fig2matplotlib.pyplot.figure

Figure instance.

Raises:
ValueError

If which_chi2 is neither None nor a valid chi2 type.

ValueError

If Rmax_arcs is not set to a numerical value.

make_chi2_plot(which_chi2=None, n_excl=0, figtype=None)

Generates a chisquare plot

The models generated are shown on a grid of parameter space. The best-fit model is marked with a black cross. The coloured circles represent models within 3 sigma confidence level (light colours and larger circles indicate smaller values of the chisquare). The small black dots indicate the models outside this confidence region.

Parameters:
which_chi2STR, optional

Which chi2 is used for determining the best models. If None, the setting from the configuration file will be used. The default is None.

nexclinteger, optional

Determines how many models (in the initial burn-in phase of the fit) to exclude from the plot. Must be an integer number. Default is 0 (all models are shown). Use this with caution!

figtypeSTR, optional

Determines the file extension to use when saving the figure. If None, the default setting is used (‘.png’).

Returns:
figmatplotlib.pyplot.figure

Figure instance.

Raises:
ValueError

If which_chi2 is neither None nor a valid chi2 type.

make_chi2_vs_model_id_plot(which_chi2=None, figtype=None)

Generates a chi2 vs. model id plot

Parameters:
which_chi2STR, optional

Which chi2 is used for determining the best models. If None, the setting from the configuration file will be used. The default is None.

figtypeSTR, optional

Determines the file extension to use when saving the figure. If None, the default setting is used (‘.png’).

Returns:
figmatplotlib.pyplot.figure

Figure instance.

Raises:
ValueError

If which_chi2 is neither None nor a valid chi2 type.

mass_plot(which_chi2=None, Rmax_arcs=None, figtype=None)

Generates cumulative mass plot

The enclosed mass profiles are shown for the mass-follows-light component (red), for the dark matter (blue), and for the sum of the two (black). The solid lines correspond to the best-fit model, the shaded areas represent 1 sigma uncertainties. The mass (in solar units) is plotted here as a function of the distancefrom the galactic centre, both in arcsec (bottom axis) and in pc (top axis).

Parameters:
which_chi2STR, optional

Which chi2 is used for determining the best models. If None, the setting from the configuration file will be used. The default is None.

Rmax_arcsnumerical value

Determines the upper range of the x-axis. Default value is None.

figtypeSTR, optional

Determines the file extension to use when saving the figure. If None, the default setting is used (‘.png’).

Returns:
figmatplotlib.pyplot.figure

Figure instance.

Raises:
ValueError

If which_chi2 is neither None nor a valid chi2 type.

ValueError

If Rmax_arcs is not set to a numerical value.

orbit_distribution(model=None, minr=None, maxr=None, nr=50, nl=61, equal_weighted_orbits=False, orientation='horizontal', figtype='.png', subset='all', getdata=False)

Make the orbit distibution plot

Plots a model’s orbit distribution in (radius, circularity) space. Orbits are split by type: [long, short, intermediate]-axis tubes and box orbits (classification is handled by orblib.classify_orbits). Each orbit only contributes to the appropriate distribution, e.g. box orbits only appear in the box-orbit panel. Compared to older versions of orbit distibution plots, this means that there is now no “stripe” at lmd_z=0, since any non short-axis tubes have been moved to their own panel. The fraction of orbits in each type is added as title. Note that individual orbits now contribute a point to the distibution, rather than a single point per orbit-bundle. This means that - if dithering>1 - the orbit distributions are sampled better compared to previous versions.

Parameters:
modeloptional, a dynamite.model.Model object

Determines which model is used for the plot. If None, the minimum chi^2 model is used (the setting in the configuration file’s parameter settings is used to determine which chi^2 is used).

minrfloat, optional

the minimum radius [kpc] to show in the plot. If None, this is set to the minimum radius of the orbit library

maxrfloat, optional

the maximum radius [kpc] to show in the plot. If None, this is set to the minimum radius of the orbit library

nrint, optional

number of radial bins, by default 50

nlint, optional

number of circularity bins, by default 61

equal_weighted_orbitsbool, optional

weight all orbit bundels equally, instead of using the model’s best-fitting weights. Useful to see the distributiuon of the full orbit libary, by default False

orientationstr, optional

arrange panels 'horizontal' or 'vertical', by default 'horizontal'

figtypestr, optional

file type extension to save the plot, by default '.png'

subsetstr, optional

either 'all' or any combination of ['long', 'short', 'intermediate', 'box'] separated by '+' e.g. 'long+box', 'box+short+intermediate'. Any order works, but the order does not affect the order of plots. By default 'all'

getdatabool, optional

whether to return the orbit distribtuion data plotted in the plot, by default False

Returns:
mpl.Figure or a tuple (mpl.Figure, np.array) if getdata=True

the figure object, and (if getdata=True) a 3D array where the 1st dimension indexes over 4 orbit types (long, int., short, box), 2nd over radii, 3rd over circularities.

Raises:
NotImplementedError

if orientation is invalid

ValueError

if orbit classes don’t match the projection tensor or orbit class names are invalid

orbit_plot(model=None, Rmax_arcs=None, figtype=None)

Generates an orbit plot for the selected model

This plot shows the stellar orbit distribution, described as probability density of orbits; circularity (lambda_z) is represented here as a function of the distance from the galactic centre r (in arcsec).

Parameters:
modelmodel, optional

Determines which model is used for the plot. If model = None, the model corresponding to the minimum chisquare (so far) is used; the setting in the configuration file’s parameter settings is used to determine which chisquare to consider. The default is None.

Rmax_arcsnumerical value

upper radial limit for orbit selection, in arcsec i.e only orbits extending up to Rmax_arcs are plotted

figtypeSTR, optional

Determines the file extension to use when saving the figure. If None, the default setting is used (‘.png’).

Returns:
figmatplotlib.pyplot.figure

Figure instance.

Raises:
ValueError

If Rmax_arcs is not set to a numerical value.

plot_kinematic_maps(model=None, kin_set=0, cbar_lims='default', figtype=None, **kwargs)

Generates a kinematic map of a model with v, sigma, h3, h4…

Maps of the surface brightness, mean line-of-sight velocity, velocity dispersion, and higher order Gauss-Hermite moments are shown. The first row are data, the second row the best-fit model, and the third row the residuals.

Parameters:
modelmodel, optional

Determines which model is used for the plot. If model = None, the model corresponding to the minimum chisquare (so far) is used; the setting in the configuration file’s parameter settings is used to determine which chisquare to consider. The default is None.

kin_setinteger or ‘all’

Determines which kinematic set to use for the plot. The value of this parameter should be the index of the data set (e.g. kin_set=0 , kin_set=1). The default is kin_set=0. If kin_set=’all’, several kinematic maps are produced, one for each kinematic dataset. A list of (fig,kin_set_name) is returned where fig are figure objects and kin_set_name are the names of the kinematics sets.

cbar_limsSTR

Determines which set of values is used to determine the limiting values defining the colorbar used in the plots. Accepted values: ‘model’, ‘data’, ‘combined’, ‘default’. The default is ‘data’ for GaussHermite kinematics, and [0,3] for BayesLOSVD kinematics where reduced chi2 values are plotted.

figtypeSTR, optional

Determines the file extension to use when saving the figure. If None, the default setting is used (‘.png’).

Returns:
list or matplotlib.pyplot.figure

if kin_set == ‘all’, returns (matplotlib.pyplot.figure, string), i.e. Figure instances along with kinemtics name or figure instance else, returns a matplotlib.pyplot.figure

Raises:
ValueError

If kin_set is not smaller than the number of kinematic sets.

ValueError

If cbar_lims is not one of ‘model’, ‘data’, or ‘combined’.

qpu_plot(which_chi2=None, Rmax_arcs=None, figtype=None)

Generates triaxiality plot

The intrinsic flattenings q (C/A) and p (B/A) are shown here, with the blue and black lines respectively, as a function of the distance from the galactic centre (in arcsec). The value of T = (1-p^2)/(1-q^2) is also shown (red line).

Parameters:
which_chi2STR, optional
Which chi2 is used for determining the best models. If None,

the setting from the configuration file will be used. The default is None.

Rmax_arcsnumerical value

Determines the upper range of the x-axis.

figtypeSTR, optional

Determines the file extension to use when saving the figure. If None, the default setting is used (‘.png’).

Returns:
figmatplotlib.pyplot.figure

Figure instance.

Raises:
ValueError

If which_chi2 is neither None nor a valid chi2 type.

ValueError

If Rmax_arcs is not set to a numerical value.

shiftedColorMap(cmap, start=0, midpoint=0.5, stop=1.0, name='shiftedcmap')

Function to offset the “center” of a colormap. Useful for data with a negative min and positive max and you want the middle of the colormap’s dynamic range to be at zero.

Parameters:
cmapThe matplotlib colormap to be altered
startOffset from lowest point in the colormap’s range.

Defaults to 0.0 (no lower offset). Should be between 0.0 and midpoint.

midpointThe new center of the colormap. Defaults to

0.5 (no shift). Should be between 0.0 and 1.0. In general, this should be 1 - vmax / (vmax + abs(vmin)) For example if your data range from -15.0 to +5.0 and you want the center of the colormap at 0.0, midpoint should be set to 1 - 5/(5 + 15)) or 0.75

stopOffset from highest point in the colormap’s range.

Defaults to 1.0 (no upper offset). Should be between midpoint and 1.0.

nameThe name of the new colormap, the default is ‘shiftedcmap’.
Returns:
newcmapThe new colormap.
exception plotter.ReorderLOSVDError

Inheritance Diagram

Inheritance diagram of plotter