API References
Scatterplot.
- scatterd.scatterd.gradient_on_density_color(X, c_rgb, labels)
Set gradient on density color.
- scatterd.scatterd.import_example(data='cancer', url=None, sep=',', verbose=3)
Import example dataset from github source.
Description
Import one of the few datasets from github source or specify your own download url link.
- param data:
Name of datasets: ‘cancer’
- type data:
str
- param url:
url link to to dataset.
- type url:
str
- param verbose:
- type verbose:
int, (default: 3)
- returns:
Dataset containing mixed features.
- rtype:
pd.DataFrame()
- scatterd.scatterd.init_figure(ax, z, dpi, figsize, visible, fig)
Initialize figure.
- 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=None, density=False, 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=False, 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=3)
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: None)) – Hex color to make a lineair gradient for the scatterplot. ‘#FFFFFF’
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.
- Return type:
Fig, ax
Examples
>>> # Import library >>> from scatterd import scatterd, import_example >>> >>> # Import example >>> df = import_example() >>> >>> # 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)
Set alpha.
- scatterd.scatterd.set_colors(X, labels, c, cmap='tab20c', gradient=None, verbose=3)
Set colors.
- scatterd.scatterd.set_fontcolor(fontcolor, label, X, cmap, verbose=3)
- scatterd.scatterd.set_marker(X, marker)
Set markers.
- scatterd.scatterd.set_size(X, s)
Set size.
- scatterd.scatterd.wget(url, writepath)
Retrieve file from url.
- Parameters:
url (str.) – Internet source.
writepath (str.) – Directory to write the file.
- Return type:
None.
Example
>>> import clustimage as cl >>> images = cl.wget('https://erdogant.github.io/datasets/flower_images.zip', 'c://temp//flower_images.zip')