You can use plt.ticks
to select certain tick positions. The way this heatmap is created, generates x ticks with text labels with names '0', '1', '2', ...
at positions 0.5, 1.5, 2.5, ....
. Therefore, you can select some of the ticks via plt.xticks(np.array([0, 2, 3, 4, 5, 6, 12, 15]) + 0.5)
.
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
df = pd.DataFrame({'FLK': np.random.uniform(0, 5, 18)})
FLK = (df[['FLK']]).T
sns.heatmap(FLK)
plt.xticks(np.array([0, 2, 3, 4, 5, 6, 12, 15]) + 0.5)
plt.tight_layout()
plt.show()
PS: Note that df.set_index('Position')
either needs to be assigned again to df
or needs the parameter inplace=True
to have some effect. In that case, the labels would be these indices, for which you can select a subset with the same plt.xticks(np.array([0, 2, 3, 4, 5, 6, 12, 15]) + 0.5)
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…