1. eject_legend() - Move Legend Outside Plot¶
Moves the legend to the right side of the plot, preventing it from obscuring data.
2. rotate_discrete_xticks() - Rotate X-Axis Labels¶
Rotates x-axis labels for better readability with long category names.
3. grab_legend() - Extract Legend to Separate Figure¶
The grab_legend() function extracts a legend to a separate figure, useful for creating independent legend files for publications.
New in this version: The remove parameter controls whether the legend is removed from the original axes:
remove=True(default): Legend is removed from the original plotremove=False: Legend remains on the original plot
Original plot still has legend: True
4. get_density() - Compute Point Density¶
Computes the local density of points for coloring scatter plots by concentration.
5. shuffle() - Randomize Data Order¶
Shuffles various data types (DataFrames, arrays, lists) to prevent plotting artifacts from data ordering.
Shuffle also works with: - NumPy arrays: <class 'numpy.ndarray'> - Lists: <class 'list'> - Tuples: <class 'tuple'>
6. number_to_color() - Map Values to Colors¶
Maps numeric values to colors from a palette, supporting both continuous and discrete binning.
Combined Example: Density + Shuffle + Number to Color¶
Combining multiple helper functions for a publication-quality visualization.
Summary¶
The BuenColors helper functions provide:
eject_legend()- Move legends outside plotsrotate_discrete_xticks()- Rotate axis labels for readabilitygrab_legend()- Extract legends to separate figuresget_density()- Compute point density for scatter plotsshuffle()- Randomize data to prevent plotting artifactsnumber_to_color()- Map numeric values to colors
These functions work seamlessly together to create publication-quality visualizations!