如何获取由pandas.DataFrame.plot创建的绘图的内部创建的colorbar实例?
以下是生成彩色散点图的示例:
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 )
ax = df.plot( kind='scatter',
x='x',
y='y',
c='score',
s=500)
ax.set_xlim( [-0.5,9.5] )
ax.set_ylim( [-0.5,9.5] )
plt.show()
Run Code Online (Sandbox Code Playgroud)
如何获取colorbar实例以便操作它,例如更改标签或设置刻度?