I am new to scipy but I managed to get the expected dendrogram. I am some more questions;
0
but its not
visible due to image border. How can I remove the border and make
the lower limit of y-axis to -1
, so that it is clearly visible.
e.g. distance between these points are 0
(13,17), (2,10), (4,8,19)0.4
My python code:
import scipy
import pylab
import scipy.cluster.hierarchy as sch
import numpy as np
D = np.genfromtxt('LtoR.txt', dtype=None)
def llf(id):
return str(id)
fig = pylab.figure(figsize=(10,10))
Y = sch.linkage(D, method='single')
Z1 = sch.dendrogram(Y,leaf_label_func=llf,leaf_rotation=90)
fig.show()
fig.savefig('dendrogram.png')
Dendrogram:
thank you.
1.fig.gca().set_ylim(-0.4,1.2)
Here gca()
returns the current axes
object, so you can give it a name
ax=fig.gca()
ax.set_ylim(-0.4,ax.get_ylim()[1])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With