Positions¶
position_beeswarm¶
- class plotnine_extra.position_beeswarm(method='swarm', cex=1.0, side=0, priority='ascending', dodge_width=None, corral='none', corral_width=0.9)[source]¶
Bases:
positionJitter points using the beeswarm algorithm
Points are arranged so that they do not overlap, producing a layout that resembles a beeswarm. The resulting shape gives a good indication of the data distribution while showing every individual observation.
- Parameters:
method (str) –
Algorithm for arranging points.
"swarm"(default): place in order, shift sideways the minimum amount to avoid overlap."compactswarm": greedy strategy for tighter packing."center"/"centre": square grid, centred."hex": hexagonal grid."square": regular square grid.
cex (float) – Scaling factor for point spacing (1-3 recommended).
side (int) –
0: both sides (default),1: right/up only,-1: left/down only.priority (str) – Order in which points are placed:
"ascending"(default),"descending","density","random","none".dodge_width (Optional[float]) – Amount of dodge between aesthetic groups.
corral (str) – How to handle runaway points:
"none"(default),"gutter","wrap","random","omit".corral_width (float) – Width of the corral region.
- REQUIRED_AES = {'x', 'y'}¶
Aesthetics required for the positioning
- setup_params(data)[source]¶
Verify, modify & return a copy of the params.
- Parameters:
data (pd.DataFrame)
- Return type:
- classmethod compute_panel(data, scales, params)[source]¶
Positions must override this function
Notes
Make necessary adjustments to the columns in the dataframe.
Create the position transformation functions and use self.transform_position() do the rest.
See also
plotnine.position_jitter.compute_panel- Parameters:
data (pd.DataFrame)
scales (pos_scales)
params (dict)
- Return type:
pd.DataFrame
position_quasirandom¶
- class plotnine_extra.position_quasirandom(method='quasirandom', width=None, varwidth=False, bandwidth=0.5, nbins=None, dodge_width=None)[source]¶
Bases:
positionJitter points using quasi-random noise to reduce overplotting
Uses density-aware quasi-random jittering (van der Corput sequence) so that the point cloud reflects the underlying data distribution, similar to a violin plot but with individual points.
- Parameters:
method (str) –
"quasirandom"(default) uses a van der Corput sequence;"pseudorandom"uses uniform random jitter.width (Optional[float]) – Maximum jitter width. If
None,0.4 * resolutionof the data axis is used.varwidth (bool) – If
True, scale the width of each group proportionally to its size relative to the largest group.bandwidth (float) – Bandwidth adjustment for the internal kernel density estimate. Values < 1 yield a tighter fit.
nbins (Optional[int]) – Number of bins for density estimation (passed through but currently unused; bandwidth controls smoothing).
dodge_width (Optional[float]) – Amount by which to dodge groups that share the same position.
Nonemeans no dodging.
- REQUIRED_AES = {'x', 'y'}¶
Aesthetics required for the positioning
- setup_params(data)[source]¶
Verify, modify & return a copy of the params.
- Parameters:
data (pd.DataFrame)
- Return type:
- classmethod compute_panel(data, scales, params)[source]¶
Positions must override this function
Notes
Make necessary adjustments to the columns in the dataframe.
Create the position transformation functions and use self.transform_position() do the rest.
See also
plotnine.position_jitter.compute_panel- Parameters:
data (pd.DataFrame)
scales (pos_scales)
params (dict)
- Return type:
pd.DataFrame
position_disjoint_ranges¶
- class plotnine_extra.position_disjoint_ranges(extend=0.0, stepsize=1.0)[source]¶
Bases:
positionVertically stack overlapping x intervals into disjoint rows.
- Parameters:
- REQUIRED_AES = {'xmax', 'xmin'}¶
Aesthetics required for the positioning
- classmethod compute_layer(data, params, layout)[source]¶
Compute position for the layer in all panels
Positions can override this function instead of compute_panel if the position computations are independent of the panel. i.e when not colliding
- Parameters:
data (pd.DataFrame)
- Return type:
pd.DataFrame
position_lineartrans¶
- class plotnine_extra.position_lineartrans(scale=(1.0, 1.0), shear=(0.0, 0.0), angle=0.0, M=None)[source]¶
Bases:
positionApply an affine 2x2 linear transformation to
xandy.- Parameters:
scale (tuple of float, default
(1, 1)) – Scale factors(sx, sy).shear (tuple of float, default
(0, 0)) – Shear factors(shx, shy).angle (float, default 0) – Rotation in degrees, applied after scale + shear.
M (array-like, optional) – A 2x2 matrix that overrides
scale/shear/angleif supplied.
- REQUIRED_AES = {'x', 'y'}¶
Aesthetics required for the positioning
- classmethod compute_layer(data, params, layout)[source]¶
Compute position for the layer in all panels
Positions can override this function instead of compute_panel if the position computations are independent of the panel. i.e when not colliding
- Parameters:
data (pd.DataFrame)
- Return type:
pd.DataFrame