我有一个树形图,它的部分足够小,标签重叠。有没有办法将 size=4 (或周围的东西)下的部分的标签移动到带有指向它的箭头的图之外,或者移动到只包含小部分标签的小图例中?
生成的树形图和代码如下。
import squarify #pip install squarify
import matplotlib.pyplot as plt
labels=["longlabel1","longlabel2","longlabel3","longlabel4","longlabel5","longlabel6","longlabel7","longlabel8","longlabel9","longlabel10","longlabel11","longlabel12",]
sizes=[1.8,1.3,10.5,13.8,7.8,6.7,9.9,12.2,12.7,10.9,7.6,4.8]
x=dict(zip(labels,sizes))
sortedDict=dict(sorted(x.items(),key=lambda item:item[1],reverse=True))
squarify.plot(sizes=list(sortedDict.values()),color=['red','blue','cyan','black','gray','green'],label=list(iter(sortedDict)),alpha=.8)
plt.axis('off')
plt.show