-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integrate optional plotting capabilities into ashist() #636
base: main
Are you sure you want to change the base?
Integrate optional plotting capabilities into ashist() #636
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 theplot
parameter toTrue
and customize plot appearance usingplot_kwargs
.Changes Made
plot
andplot_kwargs
parameters to theashist()
function.matplotlib.pyplot
based on the specified plot type.bin_edges
isTrue
.Testing
plot_kwargs
.density
andbin_edges
.Related Issues
Closes #<606>