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
- pathmap2D array
Band path map.
- symlabellist/tuple
Labels of the symmetry points.
- symidlist/tuple/array
Pixel indices of the symmetry points.
- energytklist/tuple/array | None
Energy axis ticks.
- energylabellist/tuple | None
Energy axis label.
- vline: bool | True
Vertical annotation lines.
- noendsbool | True
No vertical lines at the ends
- vlinekwdsdict | {}
Style directives of the vertical annotation lines.
- **kwdskeyword arguments
See mpes.visualization._imshow()
- Return
- axAxesObject
Axes of the generated plot.
-
mpes.visualization.
cm2palette
(cmapName)¶ Convert certain matplotlib colormap (cm) to bokeh palette.
- Parameter
- cmapNamestr
Name of the colormap/palette.
- Return
- palettelist
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
- datanumeric 2D array
the 2D data to plot
- **kwdskeyword 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
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
- axaxes 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*
- data2D numeric array
data for plotting
- ncolint
number of columns
- axistuple | (0, 1)
axes for positioning the subplot grid
- **kwdskeyword arguments
keyword
data type
meaning
mainfigsize
tuple/list
(horizontal_size, vertical_size)
cmaps
list of str
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*
- ffigure object
figure handle
- imslist
list of plot objects
- axslist
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
- dctdict
Dictionary containing the name and values of the random variables.
- ncolint
Number of columns in the plot grid.
- rvslist/tuple
List of names for the random variables (rvs).
- rvbinslist/tuple
Bin values for all random variables.
- rvrangeslist/tuple
Value ranges of all random variables.
- backendstr | ‘matplotlib’
Backend for making the plot (‘matplotlib’ or ‘bokeh’).
- legendbool | True
Option to include a legend in each histogram plot.
- histkwdsdict | {}
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
- folderstr
Directory of the file folder.
- fileslist/tuple
Directory of the files to be used for generating a movie.
- imformstr | ‘png’
Format of the images.
- movformstr | ‘avi’
Format of the generated movie.
- namestrstr | ‘movie’
Namestring (including folder path) used to save the generated movie.
- file_sortingstr | ‘forward’
File-sorting direction.
- recursivebool | False
Option to generate a recursive movie.
- retbool | False
Specify return.
- **kwdskeyword arguments
Specific parameter settings for the vocoder.
- Return
- fnameslist of str
List of (un)sorted filenames.
-
mpes.visualization.
plot_overlay
(imbot, imtop, origin='lower', **kwds)¶ Make an overlay plot of two images
- Parameters
- imbot2D array
Image at the lower layer.
- imtop2D array
Image at the top layer.
- originstr | ‘lower’
Origin of the image (‘lower’ or ‘upper’), following imshow convention
- Returns
- ffig
Figure handle
- axaxes
Figure axes object
- imslist
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
- histvals1D array
Histogram counts (e.g. vertical axis).
- edges1D array
Histogram edge values (e.g. horizontal axis).
- legendstr
Text for the plot legend.
- **kwds :
Keyword arguments for ‘bokeh.plotting.figure().quad()’.
- Return
- pobject
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
- datamatnumeric 3D array
The 3D data to plot.
- axisint
The axis to slice through.
- numberedbool
Option to print numbering onto the subplots.
- imkwdsdict
Additional arguments for the image plotting functions (imshow and contourf).
- **kwdskeyword 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
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
- imsAxesImage object
handle for the images in each subplot
- axAxesSubplot 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
- datanumeric 2D array
the 2D data to plot
- axisint | 0
the axis to cut along
- intervalfloat | 0
the interval between plots
- binningint | 1 (no binning)
number of binned rows/columns
- **kwdskeyword 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
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
- axaxes object
handle for the plot axes
-
mpes.visualization.
surf2d
(datamat, frame=True, miniaxes=False, **kwds)¶ Make 2D surface plot. Parameters
- datamatnumeric 2D array
the 2D data to plot
- framebool | True
controls whether the frame is shown
- **kwdskeyword arguments
keyword
data type
meaning
alpha
float
opacity value from 0 to 1
azimuth
float
azimuthal viewing angle (default = 0)
cmap
str
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
- ffigure object
handle for the figure
-
mpes.visualization.
toggle3d
(state=True, nb_backend=None, **kwds)¶ Switch on/off the mayavi backend Parameters
- statebool | True
on/off state of the mayavi backend
- nb_backend| None
type of rendering engine choose from ‘x3d’ (interactive) and ‘png’ (static)
- **kwdskeyword arguments
additional arguments to be passed into mayavi.mlab.init_notebook()
-
mpes.visualization.
trisurf2d
(datamat, **kwds)¶ 2D triangulated surface plot rendered using mplot3d
Parameters
- datamatnumeric 2d array
2D data for plotting
Returns
- sfPoly3DCollection object
handle for objects in the plot
- axAxes 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
- datamatnumeric 2D array
the 2D data matrix to plot
- xaxisnumeric 1D array
the x axis coordinates
- yaxisnumeric 1D array
the y axis coordinates
- ysplitint
the index of the split y position
Returns
- axuaxes object
handle for the upper subplot axes
- axlaxes object
handle for the lower subplot axes