微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何在Tkinter画布GUI的一侧添加带有值的颜色栏?

如何解决如何在Tkinter画布GUI的一侧添加带有值的颜色栏?

我正在构造一个画布图像,其中每个圆的原点,半径和颜色都映射到数据框中的数据点,如下所示:

data={'index': {0: 0,1: 1,2: 2,3: 3},'ratio': {0: 726242000000,1: 56200692307,2: 146376666666,3: 143607000000},'x': {0: 1228.7,1: 1228.7,2: 998.7,3: 946.9},'y': {0: 1654.7,1: 1326.7,2: 1685.6,3: 2129},'dimension': {0: 35,1: 35,2: 35,3: 35}}

image_factor=8
master=tkinter.Tk()
w=tkinter.Canvas(master,width=5000/image_factor,height=5000/image_factor)
minima = min(data.loc[:,'ratio'])
maxima = max(data.loc[:,'ratio'])
    
norm = matplotlib.colors.normalize(vmin=minima,vmax=maxima,clip=True)
mapper = cm.ScalarMappable(norm=norm,cmap=cm.hsv)

for index,row in sample_summary.iterrows():
    w.create_circle((data.loc[index,'x'])/image_factor,(data.loc[index,'y'])/image_factor,data.loc[index,'dimension']/(2),fill=rgb2hex((mapper.to_rgba(data.loc[index,'ratio']))),outline=rgb2hex((mapper.to_rgba(data.loc[index,width=1)

w.pack()
master.mainloop()

这将在tkinter中创建以下画布绘图。如何在画布的侧面添加带有颜色栏上的值的颜色栏?

enter image description here

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。