API References
Scatterplot.
- scatterd.scatterd.check_logger(verbose: [<class 'str'>, <class 'int'>] = 'info')
Check the logger.
- scatterd.scatterd.convert_verbose_to_new(verbose)
Convert old verbosity to the new.
- scatterd.scatterd.disable_tqdm()
Set the logger for verbosity messages.
- scatterd.scatterd.get_logger()
- scatterd.scatterd.init_figure(ax, z, dpi, figsize, visible, fig, fontsize)
Initialize figure.
- scatterd.scatterd.jitter_func(x, jitter=0.01)
Add jitter to data.
Noise is generated from random normal distribution and added to the data.
- Parameters:
x (numpy array) – input data.
jitter (float, optional) – Strength of generated noise. The default is 0.01.
- Returns:
x – Data including noise.
- Return type:
array-like
- scatterd.scatterd.normalize_between_0_and_1(X)
- scatterd.scatterd.scatterd(x, y, z=None, s=150, c=[0, 0.1, 0.4], labels=None, marker='o', alpha=0.8, edgecolor='#000000', gradient='opaque', opaque_type='per_class', density=True, density_on_top=False, norm=False, cmap='tab20c', figsize=(25, 15), dpi=100, legend=None, jitter=None, xlabel='x-axis', ylabel='y-axis', title='', fontsize=24, fontcolor=None, grid=True, fontweight='normal', args_density={'alpha': 0.66, 'bw_adjust': 0.6, 'cbar': False, 'cmap': 'Reds', 'fill': True, 'legend': False, 'thresh': 0.05}, visible=True, fig=None, ax=None, verbose='info')
Make scaterplot.
- Parameters:
x (numpy array) – 1D Coordinates x-axis.
y (numpy array) – 1D Coordinates y-axis.
z (numpy array) – 1D Coordinates z-axis.
s (Int or list/array of sizes with same size as X) – Size of the samples.
c (list/array of RGB colors with same size as X) – Color of samples in RGB colors.
labels (list of labels with same size as X) – labels of the samples.
marker (list/array of strings (default: 'o').) –
- Marker for the samples.
’x’ : All data points get this marker
(‘.’, ‘o’, ‘v’, ‘^’, ‘<’, ‘>’, ‘8’, ‘s’, ‘p’, ‘*’, ‘h’, ‘H’, ‘D’, ‘d’, ‘P’, ‘X’) : Specify per sample the marker type.
[0,3,0,1,2,1,..] : It is also possible to provide a list of labels. The markers will be assigned accordingly.
alpha (float, default: 0.8) – The alpha blending value, between 0 (transparent) and 1 (opaque).
edgecolors ((default: 'face')) –
- The edge color of the marker. Possible values:
’face’: The edge color will always be the same as the face color.
’none’: No patch boundary will be drawn.
’#FFFFFF’ : A color or sequence of colors.
gradient (String, (default: 'opaque')) –
- Hex color to make a lineair gradient using the density.
None: Do not use gradient.
opaque: Towards the edges the points become more opaque and thus not visible.
’#FFFFFF’: Towards the edges it smooths into this color
opaque_type (String, optional) –
‘per_class’: Transprancy is determined on the density within the class label (y)
’all’: Transprancy is determined on all available data points
’lineair’: Transprancy is lineair set within the class label (y)
density (Bool (default: False)) – Include the kernel density in the scatter plot.
density_on_top (bool, (default: False)) – True : The density is the highest layer. False : The density is the lowest layer.
xlabel (String, optional) – Xlabel. The default is None.
ylabel (String, optional) – Ylabel. The default is None.
title (String, optional) – Title of the figure. The default is None.
fontsize (String, optional) – The fontsize of the y labels that are plotted in the graph. The default is 16.
fontcolor (list/array of RGB colors with same size as X (default : None)) – None : Use same colorscheme as for c ‘#000000’ : If the input is a single color, all fonts will get this color.
grid (str or bool (default: False)) – False or None : Do not plot grid True : Set axis color to: ‘#dddddd’ ‘#dddddd’ : Specify color with hex
norm (Bool, optional) – Normalize datapoints. The default is False.
legend (int, default: 0) – None: Set automatically based number of labels. False : Disable. True : Best position. 1 : ‘upper right’ 2 : ‘upper left’ 3 : ‘lower left’ 4 : ‘lower right’
jitter (float, default: None) –
- Add jitter to data points as random normal data. Values of 0.01 is usually good for one-hot data seperation.
None or False: Do not add jitter
True : adds 0.01
0.05 : Specify the amount jitter to add.
cmap (String, optional) – ‘Set1’ (default) ‘Set2’ ‘rainbow’ ‘bwr’ Blue-white-red ‘binary’ or ‘binary_r’ ‘seismic’ Blue-white-red ‘Blues’ white-to-blue ‘Reds’ white-to-red ‘Pastel1’ Discrete colors ‘Paired’ Discrete colors ‘Set1’ Discrete colors
figsize (tuple, optional) – Figure size. The default is (15,10).
visible (Bool, default: True) – Visible status of the Figure. When False, figure is created on the background.
args_density (dict()) – Dictionary containing arguments for kernel density plotting.
verbose (int, (default: 'info')) – Print progress to screen. The default is ‘info’ 60: None, 40: error, 30: warning, 20: info, 10: debug
- Return type:
Fig, ax
Examples
>>> # Import library >>> from scatterd import scatterd >>> import datazets as dz >>> >>> # Import example >>> # pip install datazets >>> df = dz.get(data='cancer') >>> >>> # Simple scatter >>> fig, ax = scatterd(df['tsneX'], df['tsneY'], edgecolor='#FFFFFF') >>> >>> # Scatter with labels >>> fig, ax = scatterd(df['tsneX'], df['tsneY'], labels=df['labx']) >>> >>> # Scatter with labels >>> fig, ax = scatterd(df['tsneX'], df['tsneY'], labels=df['labx']) >>> >>> # Scatter with gradient >>> fig, ax = scatterd(df['tsneX'], df['tsneY'], z=df['tsneY'], labels=df['labx'], gradient='#FFFFFF') >>> >>> # Change cmap >>> fig, ax = scatterd(df['tsneX'], df['tsneY'], labels=df['labx'], gradient='#FFFFFF', cmap='Set2') >>> >>> # Scatter with density >>> fig, ax = scatterd(df['tsneX'], df['tsneY'], labels=df['labx'], density=True) >>> fig, ax = scatterd(df['tsneX'], df['tsneY'], labels=df['labx'], density=False, gradient='#FFFFFF', edgecolor='#FFFFFF') >>> fig, ax = scatterd(df['tsneX'], df['tsneY'], labels=df['labx'], density=True, gradient='#FFFFFF', edgecolor='#FFFFFF') >>> fig, ax = scatterd(df['tsneX'], df['tsneY'], labels=df['labx'], density=True, gradient='#FFFFFF', c=None) >>> fig, ax = scatterd(df['tsneX'], df['tsneY'], labels=df['labx'], density=True, density_on_top=True, args_density={'alpha': 0.3}, gradient='#FFFFFF', edgecolor='#FFFFFF', grid=True, fontweight='normal', fontsize=26, legend=2) >>> >>> # Scatter with density and gradient >>> fig, ax = scatterd(df['tsneX'], df['tsneY'], labels=df['labx'], density=True, gradient='#FFFFFF') >>>
References
Documentation: https://erdogant.github.io/scatterd/
Colormap: https://matplotlib.org/examples/color/colormaps_reference.html
- scatterd.scatterd.set_alpha(X, alpha, gradient, opaque, verbose=None)
Set alpha.
- scatterd.scatterd.set_colors(X, labels, c, cmap='tab20c', gradient=None, opaque_type='per_class', verbose=None)
Set colors.
- scatterd.scatterd.set_fontcolor(fontcolor, label, X, cmap, verbose=None)
- scatterd.scatterd.set_logger(verbose: [<class 'str'>, <class 'int'>] = 'info')
Set the logger for verbosity messages.
- Parameters:
verbose ([str, int], default is 'info' or 20) – Set the verbose messages using string or integer values. * [0, 60, None, ‘silent’, ‘off’, ‘no’]: No message. * [10, ‘debug’]: Messages from debug level and higher. * [20, ‘info’]: Messages from info level and higher. * [30, ‘warning’]: Messages from warning level and higher. * [50, ‘critical’]: Messages from critical level and higher.
- Returns:
None.
> # Set the logger to warning
> set_logger(verbose=’warning’)
> # Test with different messages
> logger.debug(“Hello debug”)
> logger.info(“Hello info”)
> logger.warning(“Hello warning”)
> logger.critical(“Hello critical”)
- scatterd.scatterd.set_marker(X, marker)
Set markers.
- scatterd.scatterd.set_size(X, s)
Set size.