giotto-tda icon indicating copy to clipboard operation
giotto-tda copied to clipboard

No visualization after plot_diagram

Open ghoshanirban opened this issue 11 months ago • 8 comments

I am fiddling with the code provided at https://giotto-ai.github.io/gtda-docs/latest/notebooks/vietoris_rips_quickstart.html The code runs fine, but I am not getting visualization output after

from gtda.plotting import plot_diagram

i = 0
plot_diagram(diagrams[i])

I have tried PyCharm and the terminal on Ubuntu 22.04. Is anyone else facing the same issue?

ghoshanirban avatar Mar 11 '24 13:03 ghoshanirban

Hi, I ran into the same issue when I ran the code in spyder (also Ubuntu 22.04). Turns out it works in Jupyter notebook. Looks like somehow the plotting method is written for notebook.

https://github.com/giotto-ai/giotto-tda/issues/661

beew avatar Mar 19 '24 21:03 beew

Looking at the code: the method is giving back a fig but it is not displaying it (this is what happens automatically on a notebook)

Try with

plot_diagram(diagrams[i]).show()

Or

print(plot_diagram(diagrams[i]))

VascoSch92 avatar Mar 19 '24 21:03 VascoSch92

Looking at the code: the method is giving back a fig but it is not displaying it (this is what happens automatically on a notebook)

Try with

plot_diagram(diagrams[i]).show()

Or

print(plot_diagram(diagrams[i]))

Thank you; show() worked with PyCharm and the plot got opened in a browser window. Matplotlib support would have been great. Any ideas on how to use it in this case?

ghoshanirban avatar Mar 21 '24 13:03 ghoshanirban

The method name is really bad because it is not plotting but returning a plot, and then you have to plot it. I will suggest to rename that as get_diagram, generate_diagram, ....

Matplotlib support would have been great. Any ideas on how to use it in this case?

What do you mean? Can you give some more details or an user-case? :-)

VascoSch92 avatar Mar 21 '24 13:03 VascoSch92

I wondered if the plot can be exported to a pdf generated using Matplotlib.

ghoshanirban avatar Mar 21 '24 13:03 ghoshanirban

Give a look here. :-)

And here there is the documentation on matplotlib.

VascoSch92 avatar Mar 21 '24 13:03 VascoSch92

Thanks! I was expecting gudhi-like support:

gudhi.plot_persistence_barcode(barcodes) plt.savefig("persistence-barcode.pdf", format="pdf", bbox_inches="tight")

Do we have this kind of support for giotto-tda?

ghoshanirban avatar Mar 21 '24 13:03 ghoshanirban

@ghoshanirban we do not currently have the feature you mention: we would gladly accept a PR from you adding this if you are interested however!

matteocao avatar May 30 '24 02:05 matteocao