Skip to content

Class ProjectedPlotUtils for plotting encoded data#16

Open
Monte95 wants to merge 4 commits intoAG-Peter:masterfrom
Monte95:master
Open

Class ProjectedPlotUtils for plotting encoded data#16
Monte95 wants to merge 4 commits intoAG-Peter:masterfrom
Monte95:master

Conversation

@Monte95
Copy link
Copy Markdown

@Monte95 Monte95 commented May 12, 2022

I have been using EncoderMap for a while, and I have come up with different functions during my research that I hope could be of common interest.

I have created a class called ProjectedPlotUtils with different methods to plot and/or compute different quantities from the projected.npy encoded data.

The methods are the following:

  • kde_encodermap:

Plot KDE of EncoderMap encoded data.

  • covered_area:

Calculate the total covered area of an EncoderMap plot as the total number of non-empty bins.

  • hist_plot_projected:

Plot the projected EncoderMap points as a 2D histogram.

  • minima_hist_projected:

Obtain position and number of minima (bins with value < threshold) in a certain interval of the EncoderMap plot, and plot them.

  • minima_hist:

Obtain position and number of minima (bins with value < threshold) in a defined interval of the EncoderMap plot.

  • obtain_minima_frames:

Obtain the trajectory frames corresponding to minimum values in the histogram2D plot.

@TobiasLe
Copy link
Copy Markdown
Member

Hi Daniele,

That looks great. Thanks for your contribution!
Here are a couple of thoughts from my side:

  • What is the best location for code like this? There is already a plot.py file with some plotting code. Maybe it would be best to integrate the code there, or we could make a "contributed" folder and add community contributions like this to that folder. If we go for integrating it into plot.py, I think it would be nice if all plotting functions shared a similar structure, which leads the the next point.
  • What is the best structure for a plotting function? Your functions basically take a file name and (optionally) save a png file. That's great to quickly obtain a predefined plot, but it does not allow for a lot of flexibility. For example in the distance_histogram function I chose a different strategy. It optionally takes a matplotlib axes object as input and returns this axes object after the plotting is done. This way the user has the opportunity to tweak the plot after using the function, the user has the opportunity to plot something else in the same axes, or to make this plot a part of a figure with multiple subplots etc. We could still add a save option to quickly save the plot as is. I think this makes a lot of sense because of the flexibility it allows, but I am open for discussion.
  • How do we deal with additional dependencies like pandas and seaborn? If we keep code like this a bit sperate, e.g. in a "contributed" folder that is not automatically imported with import encodermap, we could leave it up to the user to install additional dependences if they want to use the contributed code.

Maybe there are also some thoughts form the @AG-Peter/phd_students

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants