mrzv / dionysus

Library for computing persistent homology
http://mrzv.org/software/dionysus2
Other
146 stars 31 forks source link

added labels to plots and handled Deprecation warnings #18

Closed tarjebargheer closed 6 years ago

tarjebargheer commented 6 years ago

For pitching persistent homology to some clients, I thought it would look better with labels on some of the plots. Feel free to use if desired - I have also modified the code to handle deprecation warnings of matplotlib (specified handles on the axis objects that are used instead of plt directly)

mrzv commented 6 years ago

You added build/bindings/python/dionysus/plot.py. I think you want it without build. Please fix that, and I'll look at the actual diff.

mrzv commented 6 years ago

BTW, you can add labels with the existing code as follows:

import dionysus as d
import matplotlib.pyplot as plt

d.plot.plot_diagram(dgms[1])

plt.axes().set_xlabel("birth")
plt.axes().set_ylabel("death")

plt.show()
tarjebargheer commented 6 years ago

When I do that on the existing code using matplotlib 2.1.2, I get the following Deprecation Warning:

MatplotlibDeprecationWarning: Adding an axes using the same arguments as a previous axes currently reuses the earlier instance. In a future version, a new instance will always be created and returned. Meanwhile, this warning can be suppressed, and the future behavior ensured, by passing a unique label to each axes instance. warnings.warn(message, mplDeprecation, stacklevel=1)

so I modified the code with the plotting routines running on the specifix axis in matplotlib - which might not be necessary before these matplotlib changes are implemented... staying close to your original code is fine with me... I will remove the build/ pull request as well

tarjebargheer commented 6 years ago

Thanks, I have tried to follow your requests - and it should probably be better at handling the upcoming deprecation. apparently, colorbar takes the axes through an ax parameter and lives on the figure.

mrzv commented 6 years ago

Looks good. Thanks. Merging.