Home > front end >  Add x-tick marks in figure
Add x-tick marks in figure

Time:10-08

When I plot a dendrogram enter image description hereusing the following code, t-ticks are shown while x-ticks are hidden. I'd like to add y-tick marks as well. How can I do that?

from scipy.cluster import hierarchy
import matplotlib.pyplot as plt

ytdist = np.array([662., 877., 255., 412., 996., 295., 468., 268.,
                   400., 754., 564., 138., 219., 869., 669.])
Z = hierarchy.linkage(ytdist, 'single')
plt.figure()
dn = hierarchy.dendrogram(Z)

CodePudding user response:

If you want to add the tick marks on the x axis you can add the line plt.tick_params(bottom='on')

from scipy.cluster import hierarchy
import matplotlib.pyplot as plt
import numpy as np

ytdist = np.array([662., 877., 255., 412., 996., 295., 468., 268.,
                   400., 754., 564., 138., 219., 869., 669.])
Z = hierarchy.linkage(ytdist, 'single')
plt.figure()

dn=hierarchy.dendrogram(Z)
plt.tick_params(bottom='on')

The output gives me the plot below with the tick marks on the x-axisenter image description here

  • Related