私信  •  关注

matt_s

matt_s 最近创建的主题
matt_s 最近回复了
11 年前
回复了 matt_s 创建的主题 » 如何在Python中更改Colorbar标签?

这并不完全相同,但您可以使用matplotlib进行绘图:

import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import itertools as it

# [ (0,0), (0,1), ..., (9,9) ]
xy_positions = list( it.product( range(10), range(10) ) )

df = pd.DataFrame( xy_positions, columns=['x','y'] )

# draw 100 floats
df['score'] = np.random.random( 100 )

fig = plt.figure()
ax = fig.add_subplot(111)

s = ax.scatter(df.x, df.y, c=df.score, s=500)
cb = plt.colorbar(s)
cb.set_label('desired_label')

ax.set_xlim( [-0.5,9.5] )
ax.set_ylim( [-0.5,9.5] )

plt.show()