aklab.mpls module#
Convinience function for Matplotlib
- class aklab.mpls.Multiple(denominator=2, number=3.141592653589793, latex='\\pi')[source]#
Bases:
object
Matplotlib formatter
- aklab.mpls.complex_mesh(shape, xlim, ylim)[source]#
Generate complex meshgrid. Useful for complex function plots and for genera 3D plots.
- Parameters
shape (array like) – shape = (nx,ny)
xlim (array like) – limits for real coordinate
ylim (array like) – limits for imaginary coordintae
- Return type
float X and complex Y meshgrids.
- aklab.mpls.figprep(width=246, subplots=[1, 1], dpi=100, **kws)[source]#
Create matplotlib figure with given width in points
- Parameters
width (float) – figure width in points
subplots (aray-like) – [1,1] by default. The number of rows and columns.
dpi (int) – figure dpi, useflu to adjust JupyterLab figure size
- Returns
(fig, axs), matplotlib.pylab.subplots
- Return type
tuple
- aklab.mpls.font_setup(size=13, weight='normal', family='serif', color='None', fontname='Sans')[source]#
Set-up font for matplotlib using rc, see https://matplotlib.org/stable/tutorials/text/text_props.html specific for family fontnames: [‘Sans’ | ‘Courier’ | ‘Helvetica’ …]
- Parameters
family (string) – [ ‘serif’ | ‘sans-serif’ | ‘cursive’ | ‘fantasy’ | ‘monospace’ ]
weight (string) – [ ‘normal’ | ‘bold’ | ‘heavy’ | ‘light’ | ‘ultrabold’ | ‘ultralight’]
size (float) – 18 by default
color (string) – any matplotlib color
- aklab.mpls.grid_visual(ax, alpha=[0.1, 0.3])[source]#
Sets grid on and adjusts the grid style.
- Parameters
ax (matplotlib.pylab.axes) – Axes where the grid will be displayed.
alpha (array-like) – alpha = [minor alpha, major alpha] - transparancy of grid lines
- aklab.mpls.hand(minute, hours=0, l=2, o=0, angle=0.06544984694978735, hour=False, **kws)[source]#
Draw clock hand
- aklab.mpls.ltexp(val, decplace=1, short=False)[source]#
- Converts float to the scientific notation LaTeX string,
\(1.23e31 \rightarrow 1.23\times 10^{31}\)
- Parameters
val (float) – number to convert
decplace (int) – number of decimal places to display in the pre-exponent
short (bool) – if True, only shows exponent part
- aklab.mpls.multiple_formatter(denominator=2, number=3.141592653589793, latex='\\pi')[source]#
Formatter with letters, multiple of pi
- aklab.mpls.plot_circ(r=1, o=0j, **kws)[source]#
Plot a circle.
- Parameters
r (float) – radius
o (complex) – origin
kws (dict) – keyword arguments for matplotlib.pyplot.plot
- aklab.mpls.plot_color_gradients(category, cmap_list)[source]#
Create figure and adjust figure height to number of colormaps Modified from https://matplotlib.org/stable/tutorials/colors/colormaps.html
- aklab.mpls.polygon(n=6)[source]#
Calculate vertices for an n-gone, inscirbed in a unit circle. First vertice at 1.
- aklab.mpls.set_size(width, fraction=1, subplots=(1, 1), ratio='golden')[source]#
Set figure dimensions to avoid scaling in LaTeX.
- Parameters
width (float or string) – Document width in points, or string of predined document type
fraction (float, optional) – Fraction of the width which you wish the figure to occupy
subplots (array-like, optional) – The number of rows and columns of subplots.
ratio (float or string.) – ratio = fig_hight_pt/fig_width_pt. If ‘golden’ equals to golden ratio
- Returns
fig_dim – Dimensions of figure in inches
- Return type
tuple
- aklab.mpls.set_tick_size(ax, size)[source]#
Set matplotlib axis tick sizes For some reason the length from style is ignored.
- Parameters
ax (matplotlib.pylab.axes) – axes for adjustment
size (array-like) – size = [width_major, length_major, width_minor, length_minor]
- aklab.mpls.show_analog_time(hours, minutes, r=2, c='C0', o=0, fontsize=10)[source]#
Draw a clock with two hands
- aklab.mpls.ticks_visual(ax, size=[7, 4, 1, 0.8], which='both')[source]#
Makes auto minor and major ticks for matplotlib figure and adjusts ticks sizes.
- Parameters
ax (matplotlib.pylab.axes) – axes
size (array-like) – size = [l1,l2,w1,w2] length and width for major (1) and minor (2) ticks
which (string) – which = [‘x’| ‘y’ | ‘both’] - set auto minor locator