Visualization (mpes.visualization)

Custom methods for visualizing 2D-4D datasets for ARPES and beyond

@author: R. Patrick Xian

class mpes.visualization.MidpointNormalize(vmin=None, vmax=None, midpoint=None, clip=False)
mpes.visualization.bandpathplot(pathmap, symlabel, symid, energytk=None, energylabel=None, vline=True, noends=True, vlinekwds={}, **kwds)

Band path map (band dispersion in sampled k path within Brillouin zone).

Parameters

pathmap: 2D array

Band path map.

symlabel: list/tuple

Labels of the symmetry points.

symid: list/tuple/array

Pixel indices of the symmetry points.

energytk: list/tuple/array | None

Energy axis ticks.

energylabel: list/tuple | None

Energy axis label.

vline: bool | True

Vertical annotation lines.

noends: bool | True

No vertical lines at the ends

vlinekwds: dict | {}

Style directives of the vertical annotation lines.

**kwds: keyword arguments

See mpes.visualization._imshow().

Return

ax: AxesObject

Axes of the generated plot.

mpes.visualization.cm2palette(cmapName)

Convert certain matplotlib colormap (cm) to bokeh palette.

Parameter

cmapName: str

Name of the colormap/palette.

Return

palette: list

List of colors in hex representation (a bokoeh palette).

mpes.visualization.colormesh2d(data, **kwds)

Efficient one-line color mesh plot of a 2D data matrix

Parameters

data: numeric 2D array

The 2D data to plot.

**kwds: keyword arguments

keyword

data type

meaning

figsize

tuple/list

(horizontal_size, vertical_size)

x

1D array

x axis coordinates

y

1D array

y axis coordinates

xlabel

str

x axis label

ylabel

str

y axis label

colormap

str

matplotlib colormap string

cscale

str/dict

‘’ (default), ‘linear’, ‘log’, ‘gammaA-b’, dictionary with keys [‘midpoint’, ‘vmin’, ‘vmax’] for bilinear normalization

levels

1D array

explicit contour levels (ignores ncontour if not None)

ncontour

int

number of contours (ignores levels if not None)

plottype

str

‘pcolormesh’ or ‘contourf’

plotaxes

AxesObject

supply an existing AxesObject to plot on

vmin

float

minimum value of colormap

vmax

float

maximum value of colormap

ax_labelsize

int

font size of axis text labels

tk_labelsize

int

font size of axis tick labels

Return

ax: axes object

Handle for the plot axes.

mpes.visualization.fit_parameter_plot(data, ncol, axis=0, 1, **kwds)

Plot of actual value, absolute and relative changes of the fitting parameters.

Parameters

data: 2D numeric array

data for plotting

ncol: int

number of columns

axis: tuple | (0, 1)

axes for positioning the subplot grid

**kwds: keyword arguments

keyword

data type

meaning

mainfigsize

tuple/list

(horizontal_size, vertical_size)

cmaps

list of str

matplotlib colormap string

cscales

mixed list

specification of color scaling for each plot

cbars

list of bool

specification of colorbars

ncontours

list of int

number of contours for each subplot

plottypes

list of str

plottype for each subplot

Returns

f: figure object

figure handle

ims: list

list of plot objects

axs: list

list of axes objects

mpes.visualization.grid_histogram(dct, ncol, rvs=['X', 'Y', 't', 'ADC'], rvbins=[80, 80, 80, 80], rvranges=[0, 1800, 0, 1800, 68000, 74000, 0, 500], backend='matplotlib', legend=True, histkwds={}, legkwds={}, **kwds)

Grid plot of multiple 1D histograms.

Parameters

dct: dict

Dictionary containing the name and values of the random variables.

ncol: int

Number of columns in the plot grid.

rvs: list/tuple

List of names for the random variables (rvs).

rvbins: list/tuple

Bin values for all random variables.

rvranges: list/tuple

Value ranges of all random variables.

backend: str | ‘matplotlib’

Backend for making the plot (‘matplotlib’ or ‘bokeh’).

legend: bool | True

Option to include a legend in each histogram plot.

histkwds: dict | {}

Keyword arguments for histogram plots.

legkwds: dict | {}

Keyword arguments for legends.

**kwds: keyword arguments

mpes.visualization.initmpl()

Initialize mpes plot style

mpes.visualization.moviemaker(folder, files=None, imform='png', movform='avi', namestr='movie', file_sorting='forward', recursive=False, ret=False, **kwds)

Generate a movie file from a stack of images

Parameters

folder: str

Directory of the file folder.

files: list/tuple

Directory of the files to be used for generating a movie.

imform: str | ‘png’

Format of the images.

movform: str | ‘avi’

Format of the generated movie.

namestr: str | ‘movie’

Namestring (including folder path) used to save the generated movie.

file_sorting: str | ‘forward’

File-sorting direction.

recursive: bool | False

Option to generate a recursive movie.

ret: bool | False

Specify return.

**kwds: keyword arguments

Specific parameter settings for the vocoder.

Return

fnames: list of str

List of (un)sorted filenames.

mpes.visualization.plot_overlay(imbot, imtop, origin='lower', **kwds)

Make an overlay plot of two images

Parameters

imbot: 2D array

Image at the lower layer.

imtop: 2D array

Image at the top layer.

origin: str | ‘lower’

Origin of the image (‘lower’ or ‘upper’), following imshow convention.

Returns

f: fig

Figure handle.

ax: axes

Figure axes object.

ims: list

List of image objects.

mpes.visualization.plot_single_hist(histvals, edges, legend=None, **kwds)

Bokeh-based plotting of a single histogram with legend and tooltips.

Parameters

histvals: 1D array

Histogram counts (e.g. vertical axis).

edges: 1D array

Histogram edge values (e.g. horizontal axis).

legend: str

Text for the plot legend.

**kwds:

Keyword arguments for ‘bokeh.plotting.figure().quad()’.

Return

p: object

An instance of ‘bokeh.plotting.figure()’ as a plot handle.

mpes.visualization.sliceview3d(datamat, axis=0, numbered=True, imkwds={}, **kwds)

3D matrix slices displayed in a grid of subplots.

Parameters

datamat: numeric 3D array

The 3D data to plot.

axis: int

The axis to slice through.

numbered: bool

Option to print numbering onto the subplots.

imkwds: dict

Additional arguments for the image plotting functions (imshow and contourf).

**kwds: keyword arguments

keyword

data type

meaning

aspect

str/numeric

aspect ratio of each subplot, from [‘auto’, ‘equal’ or scalar]

ncol

int

number of columns in subplot grid

nrow

int

number of rows in subplot grid

figsize

tuple/list

figure size, (vertical_size, horizontal_size)

flipdir

str

flip up-down or left-right of the matrix (‘ud’, ‘lr’)

colormap

str

matplotlib colormap string

cscale

str

colormap scaling (‘’(default), ‘log’, ‘linear’, ‘midpointx’, or ‘gammaA-b’, see below)

vmin

numeric

minimum of the color scale

vmax

numeric

maximum of the color scale

numcolor

str

color code for subplot number

numpos

tuple

(Y, X) position of the text on the subplots

numsize

int

fontsize of the subtitle within a subplot

numtext

str

subtitle text within a subplot

wspace

float

width spacing between subplots

hspace

float

height spacing betweens subplots

plottype

str

‘imshow’ (default) or ‘contourf’

maintitle

str

main title of the plot

axisreturn

str

‘flattened’ or ‘nested’, return format of axis object

Returns

ims: AxesImage object

Handle for the images in each subplot.

ax: AxesSubplot object

Handle for the subplot axes.

mpes.visualization.stackedlineplot(datamat, axis=0, interval=0, binning=1, **kwds)

Stacked line plots (used for visualizing energy or momentum dispersion curves)

Parameters

data: numeric 2D array

the 2D data to plot

axis: int | 0

the axis to cut along

interval: float | 0

the interval between plots

binning: int | 1 (no binning)

number of binned rows/columns

**kwds: keyword arguments

keyword

data type

meaning

figsize

tuple/list

(horizontal_size, vertical_size)

x

1D array

x axis values

xlabel

str

x axis label

ylabel

str

y axis label

cmap

str

matplotlib colormap string

axislabelsize

int

font size of axis text labels

ticklabelsize

int

font size of axis tick labels

margins

tuple/list

(xmargin, ymargin), values between 0 and 1

Return

ax: axes object

handle for the plot axes

mpes.visualization.surf2d(datamat, frame=True, miniaxes=False, **kwds)

Make 2D surface plot.

Parameters

datamat: numeric 2D array

The 2D data to plot.

frame: bool | True

Option to control whether the frame is shown.

**kwds: keyword arguments

keyword

data type

meaning

alpha

float

opacity value from 0 to 1

azimuth

float

azimuthal viewing angle (default = 0)

cmap

str

matplotlib colormap string

elevation

float

zenith viewing angle (default = 0)

bgc

tuple/list

background color in RGB values

kind

str

kind of surface plot, {‘points’, ‘wireframe’, ‘surface’}

framecolor

tuple/list

color of the frame

warp_scale

float

warp scale value from 0 to 1

Return

f: figure object

Handle for the figure.

mpes.visualization.toggle3d(state=True, nb_backend=None, **kwds)

Switch on/off the mayavi backend.

Parameters

state: bool | True

on/off state of the mayavi backend

nb_backend: | None

type of rendering engine choose from ‘x3d’ (interactive) and ‘png’ (static).

**kwds: keyword arguments

additional arguments to be passed into mayavi.mlab.init_notebook().

mpes.visualization.trisurf2d(datamat, **kwds)

2D triangulated surface plot rendered using mplot3d.

Parameters

datamat: numeric 2d array

2D data for plotting.

Returns

sf: Poly3DCollection object

Handle for objects in the plot.

ax: Axes object

Handle for the axes of the plot.

mpes.visualization.ysplitplot(datamat, xaxis, yaxis, ysplit=160)

Split-screen plot of an ARPES spectrum (intensity scaled differently for valence and conduction bands).

Parameters

datamat: numeric 2D array

the 2D data matrix to plot

xaxis: numeric 1D array

the x axis coordinates

yaxis: numeric 1D array

the y axis coordinates

ysplit: int

the index of the split y position

Returns

axu: axes object

handle for the upper subplot axes

axl: axes object

handle for the lower subplot axes