Py学习  »  Python

如何在Python中更改Colorbar标签?

Alex • 3 年前 • 1729 次点击  

如何获取pandas创建的绘图的内部创建的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()

这给了我一个这样的数字: enter image description here

如何获取colorbar实例以对其进行操作,例如更改标签或设置刻度?

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/132494
 
1729 次点击  
文章 [ 2 ]  |  最新文章 3 年前