Skip to content

Unify properties#48

Merged
jo-mueller merged 66 commits intomainfrom
unify_properties
Apr 24, 2025
Merged

Unify properties#48
jo-mueller merged 66 commits intomainfrom
unify_properties

Conversation

@jo-mueller
Copy link
Contributor

@jo-mueller jo-mueller commented Apr 22, 2025

Hi @zoccoler ,

here comes the result of my works in synchronizing functionality between the scatter and the histogram. The key changes are the _create_plot() function that creates the plot. I added new functions _draw_selection_on_plot and color_indices_to_rgba which, as the name suggests, handle the overlay drawing and make it easier to retrieve the color_indices as rgba values without the need to access private methods.

I also replaced some code by functions I found elsewhere. For the statistical histogram, for instance, there's a scipy function that essentially does that :)

PS: Tests haven't been updated yet (WIP) and will likely fail.

Long copilot description

This pull request introduces a new abstract base class, Artist, in the src/biaplotter/artists_base.py file. The class is designed to serve as a foundation for creating customizable plotting components in the BiAPlotter framework. It provides a structured interface for managing data, colormaps, and visibility, while also emitting signals for changes in data and color indices.

New Abstract Base Class for Plotting (Artist)

  • Class Definition: Added the Artist class, which inherits from ABC and defines an interface for plotting components. It includes parameters for axes (ax), data (data), colormaps (overlay_colormap), and color indices (color_indices).
  • Signals: Introduced data_changed_signal and color_indices_changed_signal to notify changes in the data and color_indices properties, respectively.
  • Abstract Methods: Defined three abstract methods—_create_plot, _draw_selection_on_plot, and color_indices_to_rgba—to enforce implementation in derived classes.

Plot Management and Customization

  • Dynamic Plot Updates: Added methods like _update_axes_limits, _modify_plot, and _remove_artists to dynamically adjust axes limits, modify plots, and remove plot elements.

zoccoler and others added 27 commits April 17, 2025 15:09
Co-Authored-By: Marcelo Zoccoler <26173597+zoccoler@users.noreply.github.com>
Co-Authored-By: Marcelo Zoccoler <26173597+zoccoler@users.noreply.github.com>
…ethods

Co-Authored-By: Marcelo Zoccoler <26173597+zoccoler@users.noreply.github.com>
Co-Authored-By: Marcelo Zoccoler <26173597+zoccoler@users.noreply.github.com>
@jo-mueller jo-mueller added the enhancement New feature or request label Apr 22, 2025
zoccoler and others added 13 commits April 23, 2025 12:29
…flag to True to avoid showing warning on default overlay_colormap
This avoids a bug that would color a bin with a different color when the median is calculated over an even number of elements and the middle elements are different. For example, the median of [1, 1, 3, 3] would be 2. This has the effect of painting that bin with color number 2, which was never assigned by the user. To avoid this, we chose here to always get the lower median (1 in this example).
Co-Authored-By: Marcelo Zoccoler <26173597+zoccoler@users.noreply.github.com>
Co-Authored-By: Marcelo Zoccoler <26173597+zoccoler@users.noreply.github.com>
…catter

Co-Authored-By: Marcelo Zoccoler <26173597+zoccoler@users.noreply.github.com>
Co-Authored-By: Marcelo Zoccoler <26173597+zoccoler@users.noreply.github.com>
Co-Authored-By: Marcelo Zoccoler <26173597+zoccoler@users.noreply.github.com>
Co-Authored-By: Marcelo Zoccoler <26173597+zoccoler@users.noreply.github.com>
@jo-mueller
Copy link
Contributor Author

@zoccoler I think this is good to go. I fixed the tests and updated the documentation notebooks 👍

@zoccoler
Copy link
Contributor

Hi @jo-mueller ,

I approved the changes and added back the functionality of cmin (now a property), which can set a minimal counts value for the histogram (values below that will be turned to np.nan and, therefore, become transparent). The default value is 0 as before, so nothing should change with this value.

Minor updates are:

  • updating notebooks with these changes (cmin property and reset method)
  • documentation
  • pinning minimal numpy version (due to using np.nanpercentile now)
  • bumping biaplotter version to 0.2.0

If you agree, please merge and I am also in favor of making the new release right after that.

@jo-mueller
Copy link
Contributor Author

@zoccoler Awe-some! Will merge and release and then be able to merge a bunch of stuff right after that for the clusters-plotter 👍

@jo-mueller jo-mueller merged commit 233336f into main Apr 24, 2025
21 checks passed
@jo-mueller jo-mueller deleted the unify_properties branch April 24, 2025 09:46
This was referenced May 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants