Closed battersbot closed 7 years ago
I was having a problem using .plot_tree for my structure, so I thought I was inputting the structure with the wrong type. But I cannot even reproduce the example on the page: http://dendrograms.readthedocs.io/en/stable/plotting.html#making-plots-for-publications
So, it may be a larger issue? @keflavich
Thanks for the help, Cara
=================================== Here is my implementation of the example code, except for changing my path:
from astrodendro import Dendrogram from astropy.io import fits import matplotlib.pyplot as plt from astropy.io.fits import getdata path='path' image = fits.getdata(path+'PerA_Extn2MASS_F_Gal.fits') d = Dendrogram.compute(image, min_value=2.0, min_delta=1., min_npix=10) p = d.plotter() fig = plt.figure() ax = fig.add_subplot(1, 1, 1) # Plot the whole tree p.plot_tree(ax, color='black') # Highlight two branches p.plot_tree(ax, structure=8, color='red', lw=2, alpha=0.5) p.plot_tree(ax, structure=24, color='orange', lw=2, alpha=0.5) # Add axis labels ax.set_xlabel("Structure") ax.set_ylabel("Flux")
=================================== And the resulting error messages:
TypeError Traceback (most recent call last) <ipython-input-9-65bc8976f5c9> in <module>() 16 17 # Highlight two branches ---> 18 p.plot_tree(ax, structure=8, color='red', lw=2, alpha=0.5) 19 p.plot_tree(ax, structure=24, color='orange', lw=2, alpha=0.5) 20 /Users/battersby/anaconda/lib/python2.7/site-packages/astrodendro/plot.pyc in plot_tree(self, ax, structure, subtree, autoscale, **kwargs) 101 102 # Get the lines for the dendrogram --> 103 lines = self.get_lines(structures=structure, **kwargs) 104 105 # Add the lines to the axes /Users/battersby/anaconda/lib/python2.7/site-packages/astrodendro/plot.pyc in get_lines(self, structures, subtree, **kwargs) 191 else: 192 if subtree: --> 193 if type(structures[0]) is int: 194 structure = self.dendrogram[structures[0]] 195 else: TypeError: 'int' object has no attribute '__getitem__'
Fixed when updating to the developer's version! Thanks @keflavich
I was having a problem using .plot_tree for my structure, so I thought I was inputting the structure with the wrong type. But I cannot even reproduce the example on the page: http://dendrograms.readthedocs.io/en/stable/plotting.html#making-plots-for-publications
So, it may be a larger issue? @keflavich
Thanks for the help, Cara
=================================== Here is my implementation of the example code, except for changing my path:
=================================== And the resulting error messages: