Customisation#
- squap.get_font(
- font_name='Segoe UI',
- font_size=None,
- bold=False,
- italic=False,
- underline=False,
- strikethrough=False,
- overline=False,
- kerning=False,
- stretch=100,
- letter_spacing=0.0,
- word_spacing=0.0,
- **kwargs,
Creates and returns a
font object. Usually font names are allowed when a function requires a font as an argument, but this function creates more complex fonts.- Parameters:
font_name (str) – Name of the font. Can be any font on your computer. Defaults to
"Segoe UI". Aliases:font,fn.font_size (int) – Font size. Defaults to
None. This usually means thefont_sizeis 12 todo: check Aliases:size,fs.bold (bool) – Whether to make the font bold. Defaults to
False.italic (bool) – Whether to make the font italic. Defaults to
False.underline (bool) – Whether to give the font underline. Defaults to
False.strikethrough (bool) – Whether to make the font strikethrough. Defaults to
False. Alias:strikeout.overline (bool) – Whether to give the font overline. Defaults to
False.kerning (bool) – Whether to draw the font with kerning. If kerning is enabled the text is drawn a bit more compactly. Defaults to
False.stretch (int) – Stretch factor as percentage. Eg.
100is normal,200is twice as wide. Default is100.letter_spacing (float) – Extra spacing between letters in pixels. Defaults to
0.0. Alias:ls.word_spacing (float) – Extra spacing between words in pixels. Defaults to
0.0. Alias:ws.**kwargs – Aliases. See argument description for allowed aliases.
todo – setFixedPitch?, setLetterSpacing?, setWordSpacing?
- Return type:
- squap.get_gradient(
- cmap,
- style='horizontal',
- position=None,
- extend='pad',
- resolution=256,
Obtain a gradient. Gradients can sometimes be used instead of normal colors.
The gradient can be seen as a 2D image of a gradient placed depending on
position. Only the parts are shown at each pixel that is drawn by eg. a plot line. When style of the gradient is set to"horizontal"or"vertical", or"radial"without providingposition, the bounds of the gradient will be automatically determined whencurve.set_datais called. Specifypositionfor optimal performance.- Parameters:
cmap (str, dict, list or Colormap) –
The colormap used as gradient. Can either be a string, a dictionary, a list of colors or an instance of matplotlib.colors.Colormap:
str: Any matplotlib colormap name. When a colormap exists in both matplotlib and cmasher, matplotlib takes priority. Prefix with"mpl_"or"cmasher_"to select explicitly.dict: Maps positions (0–1) to colors.cmap[0]andcmap[1]are the start and end, with linear interpolation between any intermediate points.list: Colors equally spaced between 0 and 1, with linear interpolation between them.Colormap: Used directly.
style (str) –
The style of the gradient.
"horizontal": Simple left-to-right gradient."vertical": Simple top-to-bottom gradient."linear": Gradient along a line fromposition[0](tuple) toposition[1](tuple)."radial": Radial gradient with centreposition[0](tuple) and radiusposition[1](float)."conical": Constant along the radius, varying with angle.position[0](tuple) is the centre,position[1](float) is the starting angle in degrees from the positive y-axis, defaulting to 0. For"linear","radial", and"conical",positionis determined automatically if not specified.
Defaults to
"horizontal".position (tuple) – See
style.extend (str) – How the gradient behaves outside the range specified in position. Can be
"pad","repeat"or"reflect"(only applies when style is"linear"or"radial"and position is specified). Defaults to"pad".resolution (int) – The resolution of the gradient, when it is a matplotlib (or cmasher) cmap. Does not do anything when the cmap is a dict or a list. Defaults to
256.
- Returns:
A gradient object.
- Return type:
- squap.get_cmap(data, source='matplotlib')[source]#
Tool for getting cmap from different sources. Returns a function that takes a value between
0and1and returns a color based on thedataargument.If
datais of typestr,sourcedecides from which library the cmap is obtained.- Parameters:
data (str, list of ColorType or dict of float to ColorType) –
Has different behaviour depending on type:
str: Name of the cmap.
sourcespecifies from which library the cmap is obtained.dict:
data[x]is the cmap color atx, where the cmap is defined fromx=0tox=1. Every value not indatais interpolated. So e.g.datacan be{0.0: "green", 0.25: "red", 1.0: "blue"}, which would mean a cmap going from green to red rather quickly, and then slowly turning blue.list: similar to
dict, but equally spaced colors in order.
source (str) – Library to obtain cmap from if it is a string. Currently, you can choose from matplotlib and colorcet. Feel free to request more.
- Returns:
A function that interpolates to find the best approximation of the color at location
i: a value between0and1.- Return type:
- squap.cmap_to_colors(cmap, N_points)[source]#
Transform a cmap into N equally spaced colors.
- Parameters:
( (cmap) – term:callable): the used colormap (from
squap.get_cmap())N_points (int) – the number of points to retrieve
- Returns:
A shape
(N_points, 4)ndarraywhereresult[i]iscmap(i/N_points-1).- Return type:
np.ndarray