kdotpy
Loading...
Searching...
No Matches
kdotpy.ploto.toolstext Namespace Reference

Functions

 reformat_degree (s)
 LATEX FORMATTING OF AXIS AND LEGEND LABELS ###.
 
 tex_length (string)
 
 obs_latex (obsid)
 
 get_fig_unit_format (reset_cache=False)
 
 format_axis_unit (unit)
 
 format_axis_label (*arg)
 
 format_legend_label (str1, str2=None)
 
 set_xlabel (*arg)
 
 set_ylabel (*arg)
 
 set_disp_axis_label (kname, set_x=False, set_y=False)
 
 get_partext (pval, pname, accuracy=1e-10)
 TEXT ELSEWHERE ###.
 
 add_char_labels (bandchar, axis=None, fig=None, k0=None, xrange=None, yrange=None, size=None, box=True, transform=None)
 
 add_band_labels (eival, bindex, llindex=None, axis=None, fig=None, k0=None, xrange=None, yrange=None, size=None, box=True, transform=None)
 
 set_band_label_2d (label, axis=None)
 
 get_title_position (where, default=(0.5, 0.98, 'center', 'top'))
 

Variables

 _fig_unit_format = None
 AXIS (UNIT) FORMATTING ###.
 

Function Documentation

◆ add_band_labels()

kdotpy.ploto.toolstext.add_band_labels ( eival,
bindex,
llindex = None,
axis = None,
fig = None,
k0 = None,
xrange = None,
yrange = None,
size = None,
box = True,
transform = None )
Add band labels, band index or (LL index, band index).
    Places character labels near the bands at k = 0. If multiple bands bunch up
    at the same energy, concatenate the corresponding labels with commas.

    Arguments:
    eival      Array. Eigenvalues, like ddp.eival of a DiagDataPoint instance.
    bindex     Array. Band indices, like ddp.bindex of a DiagDataPoint instance.
    llindex    Array. LL indices, like ddp.llindex of a DiagDataPoint instance.
    axis       matplotlib axis instance in which the band labels should be
               drawn; if None, use the current axis
    fig        matplotlib figure instance in which the band labels should be
               drawn; if None, use the current figure
    xrange     The extent of the horizontal axis. If None, determine
               automatically.
    yrange     The extent of the vertical axis. If None, determine
               automatically.
    size       Font size
    box        If True, draw a box around the labels.
    transform  ETransform instance. Transform the energy values to a different
               vertical coordinate.

    Returns:
    matplotlib figure instance.

◆ add_char_labels()

kdotpy.ploto.toolstext.add_char_labels ( bandchar,
axis = None,
fig = None,
k0 = None,
xrange = None,
yrange = None,
size = None,
box = True,
transform = None )
Add (band) character labels.
    Places character labels near the bands at k = 0. If multiple bands bunch up
    at the same energy, concatenate the corresponding labels with commas.

    Arguments:
    bandchar   A dict instance where the keys are the labels and the items the
               energy values.
    axis       matplotlib axis instance in which the band labels should be drawn
               drawn; if None, use the current axis
    fig        matplotlib figure instance in which the band labels should be
               drawn; if None, use the current figure
    xrange     The extent of the horizontal axis. If None, determine
               automatically.
    yrange     The extent of the vertical axis. If None, determine
               automatically.
    size       Font size
    box        If True, draw a box around the labels.
    transform  ETransform instance. Transform the energy values to a different
               vertical coordinate.

    Returns:
    matplotlib figure instance.

◆ format_axis_label()

kdotpy.ploto.toolstext.format_axis_label ( * arg)
Concatenate strings and format as unit.
    If one argument is given, return that argument. Otherwise format the last
    argument as a unit string using format_axis_unit(), and concatenate the
    result to the other string arguments.

◆ format_axis_unit()

kdotpy.ploto.toolstext.format_axis_unit ( unit)
Format axis unit.
    Depending on the configuration value 'fig_unit_format', convert the raw unit
    string (input argument) into a properly formatted string. This function
    takes care of division slashes and/or exponents, for example.

◆ format_legend_label()

kdotpy.ploto.toolstext.format_legend_label ( str1,
str2 = None )
Format legend label from one or two strings.

    Arguments:
    str1, str2   One or two arguments, each being str or None. If str2 is None,
                 try to parse str1 as observable id. Otherwise, interpret str1
                 and str2 as strings for quantity and unit, respectively.

    Returns:
    label   String. TeX formatted string suitable as label for a legend (color
            bar).

◆ get_fig_unit_format()

kdotpy.ploto.toolstext.get_fig_unit_format ( reset_cache = False)

◆ get_partext()

kdotpy.ploto.toolstext.get_partext ( pval,
pname,
accuracy = 1e-10 )

TEXT ELSEWHERE ###.

Determine the auxiliary label (placed in the upper left corner, usually)

    Arguments:
    pval      Numeric, Vector instance, or None. The parameter value. If None,
              return the empty string.
    pname     String. The parameter/variable name. This may be a variable
              component like 'kx'.
    accuracy  Positive float. If the parameter value is smaller in absolute
              value, use the value 0.

    Returns:
    TeX-formatted parameter text

◆ get_title_position()

kdotpy.ploto.toolstext.get_title_position ( where,
default = (0.5, 0.98, 'center', 'top') )
Get position of the plot title.
    Arguments:
    where     Label specifying the position. Inspect the code below for
              permitted values.
    default   If where is None, 'auto' or 'automatic', return these values.

    Returns:
    x, y      Coordinates
    ha, va    Horizontal and vertical text alignment

◆ obs_latex()

kdotpy.ploto.toolstext.obs_latex ( obsid)
LaTeX string for the built-in observables + units.
    This function formats the observable and its unit into LaTeX format, which
    can be used for axis and legend labels, for example. The 'real work' is done
    in observables.obsid_to_tex(). This function provides some further
    processing for compound or derived observables.

    Arguments:
    obsid   String

    Returns:
    qstr    String. TeX formatted string for physical quantity.
    ustr    String. TeX formatted string for unit.

◆ reformat_degree()

kdotpy.ploto.toolstext.reformat_degree ( s)

LATEX FORMATTING OF AXIS AND LEGEND LABELS ###.

Replace superscript \\circ by \\degree and delete spaces

◆ set_band_label_2d()

kdotpy.ploto.toolstext.set_band_label_2d ( label,
axis = None )
Band label for 2D band plots.
    Write boxed text in the corner of a 2D dispersion plot.

    Arguments:
    label  Label text
    axis   matplotlib axis instance in which the label should be drawn; if None,
           use the current axis

    No return value.

◆ set_disp_axis_label()

kdotpy.ploto.toolstext.set_disp_axis_label ( kname,
set_x = False,
set_y = False )
Determine the label for the x axis (dispersion plots, etc.)
    This function takes the variable component, e.g., 'kx', and formats it into
    an axis label with units if appropriate. It can also apply the axis label
    immediately to the x and/or y axis in the current figure.

    Arguments:
    kname     String. The vector component, for example 'kx'.
    set_x     True or False. Whether to set the axis label as xlabel.
    set_y     True or False. Whether to set the axis label as ylabel.

    Returns
    TeX-formatted string for the axis label.

◆ set_xlabel()

kdotpy.ploto.toolstext.set_xlabel ( * arg)
Format and set x label.
    Applies format_axis_label(), sets it as xlabel and returns the string.

◆ set_ylabel()

kdotpy.ploto.toolstext.set_ylabel ( * arg)
Format and set y label.
    Applies format_axis_label(), sets it as ylabel and returns the string.

◆ tex_length()

kdotpy.ploto.toolstext.tex_length ( string)
Get a rough length estimate of the rendered tex string.

Variable Documentation

◆ _fig_unit_format

kdotpy.ploto.toolstext._fig_unit_format = None
protected

AXIS (UNIT) FORMATTING ###.