Integrate optional plotting capabilities into ashist()#636
Integrate optional plotting capabilities into ashist()#636willcollins10 wants to merge 10 commits intoxgi-org:mainfrom
Conversation
test: Added function to core.py to best understand the workflow
…ns when a pull request is made
|
@willcollins10 --- thanks for the PR! I will try to take a look this afternoon! |
|
@willcollins10 --- side note, the tests fail because the example you added in the docstring never defines |
nwlandry
left a comment
There was a problem hiding this comment.
Overall looks awesome! Three main comments: (1) move the plotting contents to a helper function and (2) add the ability to plot a scatterplot, and (3) fix the docstring so that the doctests pass. Thanks for the contribution!
| # Only execute plotting code if plot is True or a string | ||
| if plot: | ||
| try: | ||
| import matplotlib.pyplot as plt |
There was a problem hiding this comment.
If users have installed xgi, I believe that they will also have matplotlib by default, so not sure that you need to check this.
| df = hist(self.asnumpy(), bins, bin_edges, density, log_binning) | ||
|
|
||
| # Only execute plotting code if plot is True or a string | ||
| if plot: |
There was a problem hiding this comment.
Can you break this out into a modular helper function with an underscore prefix like _plot_hist or similar?
| Originally from https://github.com/jkbren/networks-and-dataviz | ||
| Examples | ||
| -------- | ||
| >>> H.nodes.degree.ashist(plot='bar', plot_kwargs={'color': 'red'}) |
There was a problem hiding this comment.
Define what H is. maybe a small example? like
H = xgi.Hypergraph([[1, 2, 3], [3, 4], [1, 3, 6]])
H.nodes.degree.ashist(plot='bar', plot_kwargs={'color': 'red'})| fig, ax = plt.subplots() | ||
|
|
||
| # Plot based on type | ||
| if plot_type == "bar": |
There was a problem hiding this comment.
can you add a "scatter" option or replace the "line" option with a scatterplot only plotting the points?
Description
This PR integrates optional plotting capabilities directly into the
ashist()function. Users can now generate plots ('bar','line', or'step') by setting theplotparameter toTrueand customize plot appearance usingplot_kwargs.Changes Made
plotandplot_kwargsparameters to theashist()function.matplotlib.pyplotbased on the specified plot type.bin_edgesisTrue.Testing
plot_kwargs.densityandbin_edges.Related Issues
Closes #<606>