Scatter
dimensionality_reduction(data, reduction_funcs, n_components, target_column, title='Dimensionality reduction plot', scaler_func='StandardScaler', size=None, show_legend=None, reduction_func_kwargs=None, plotly_kwargs=None, show=True, write_html_path=None)
¶
Create a scatter plot of the dimensionality reduction representation of
the data provided. Multiple dimensionality reduction functions can be used.
The data is scaled using the scaler_func
. If multiple functions are used,
the plots are arranged in a grid using.
make_subplots
from blitzly ⚡️.
Example:
from blitzly.plots.scatter import dimensionality_reduction
import plotly.express as px
df = px.data.iris()
fig = dimensionality_reduction(
df,
n_components=2,
target_column="species",
reduction_funcs=["PCA", "TNSE"],
)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
pd.DataFrame
|
Data to plot. |
required |
reduction_funcs |
Union[str, List[str]]
|
Dimensionality reduction function(s) to use. The following functions are supported: NMF, PCA, IncrementalPCA, KernelPCA, MiniBatchSparsePCA, SparsePCA, TruncatedSVD, TSNE. |
required |
n_components |
int
|
Number of components to use. This parameter is passed to the dimensionality reduction function. |
required |
target_column |
str
|
Column to use as the color dimension. |
required |
title |
Optional[str]
|
Title of the plot. Defaults to "Dimensionality reduction plot". |
'Dimensionality reduction plot'
|
scaler_func |
Optional[str]
|
Scaler function to use. Defaults to "StandardScaler". The following functions are supported: StandardScaler, MinMaxScaler. |
'StandardScaler'
|
size |
Optional[Tuple[int, int]
|
Size of the full plot. |
None
|
show_legend |
Optional[bool]
|
Whether to show the legend. |
None
|
show |
bool
|
Whether to show the figure. |
True
|
write_html_path |
Optional[str]
|
The path to which the histogram should be written as an HTML file. If None, the histogram will not be saved. |
None
|
Source code in blitzly/plots/scatter.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
|
multi_scatter(data, x_y_columns, modes=None, title='Scatter plot', size=None, show_legend=True, plotly_kwargs=None, show=True, write_html_path=None)
¶
Create a multi scatter plot. It can be used to visualize the relationship between multiple variables from the same Pandas DataFrame.
Example:
from blitzly.plots.scatter import multi_scatter
import numpy as np
import pandas as pd
random_a = np.linspace(0, 1, 100)
random_b = np.random.randn(100) + 5
random_c = np.random.randn(100)
random_d = np.random.randn(100) - 5
data = np.array([random_a, random_b, random_c, random_d]).T
multi_scatter(
data=pd.DataFrame(data, columns=["foo", "bar", "blitz", "licht"]),
x_y_columns=[("foo", "bar"), ("foo", "blitz"), ("foo", "licht")],
modes=["lines", "markers", "lines+markers"],
plotly_kwargs={"line": {"color": "black"}},
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
pd.DataFrame
|
Data to plot. Must be a Pandas DataFrame. |
required |
x_y_columns |
List[Tuple[str, str]]
|
List of tuples containing the x and y columns.
Those columns will be used for |
required |
modes |
Optional[List[str]]
|
List of modes for the scatter plot. If |
None
|
title |
str
|
Title of the plot. |
'Scatter plot'
|
size |
OptionalTuple[int, int]
|
Size of the plot - height and width. |
None
|
show_legend |
bool
|
Whether to show the legend. |
True
|
plotly_kwargs |
Optional[dict]
|
Additional plotly kwargs. |
None
|
show |
bool
|
Whether to show the figure. |
True
|
write_html_path |
Optional[str]
|
The path to which the histogram should be written as an HTML file. If None, the histogram will not be saved. |
None
|
Returns:
Name | Type | Description |
---|---|---|
BaseFigure |
BaseFigure
|
The multi scatter plot. |
Source code in blitzly/plots/scatter.py
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 |
|
scatter_matrix(data, dimensions=None, color_dim=None, show_upper_half=False, diagonal_visible=False, show_scale=False, title='Scatter matrix', marker_line_color='white', marker_line_width=0.5, marker_color_scale='Plasma', size=None, show_legend=False, show=True, write_html_path=None)
¶
Create a scatter matrix plot. It can be used to visualize the relationship between multiple variables. The scatter matrix is a grid of scatter plots, one for each pair of variables in the data. The diagonal plots are histograms of the corresponding variables. It is also useful for visualizing the distribution of each variable.
Example:
from blitzly.plots.scatter import scatter_matrix
import numpy as np
import pandas as pd
foo = np.random.randn(1000)
bar = np.random.randn(1000) + 1
blitz = np.random.randint(2, size=1000)
licht = np.random.randint(2, size=1000)
data = np.array([foo, bar, blitz, licht])
df = pd.DataFrame(data.T, columns=["foo", "bar", "blitz", "licht"])
scatter_matrix(
df,
dimensions=["foo", "bar", "blitz"],
color_dim=df["licht"],
title="My first scatter matrix 🙃",
show_upper_half=True,
diagonal_visible=False,
marker_color_scale="Rainbow",
marker_line_color="blue",
size=(500, 500),
)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
pd.DataFrame
|
Data to plot. |
required |
dimensions |
Optional[List[str]]
|
List of columns to plot. If |
None
|
color_dim |
Optional[Union[pd.Series, List[str], NDArray]]
|
Color dimension. If |
None
|
show_upper_half |
bool
|
Show upper half of the scatter matrix. |
False
|
diagonal_visible |
bool
|
Show diagonal part of the matrix. |
False
|
show_scale |
bool
|
Show color scale. |
False
|
title |
str
|
Title of the plot. |
'Scatter matrix'
|
marker_line_color |
str
|
Color of the marker line. |
'white'
|
marker_line_width |
float
|
Width of the marker line. |
0.5
|
marker_color_scale |
str
|
Color scale of the markers. |
'Plasma'
|
size |
Optional[Tuple[int, int]
|
Size of the plot. |
None
|
show_legend |
Optional[bool]
|
Whether to show the legend. |
False
|
show |
bool
|
Whether to show the figure. |
True
|
write_html_path |
Optional[str]
|
The path to which the histogram should be written as an HTML file. If None, the histogram will not be saved. |
None
|
Returns:
Name | Type | Description |
---|---|---|
BaseFigure |
BaseFigure
|
The scatter matrix plot. |
Source code in blitzly/plots/scatter.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
|