标签: python-3.x pandas matplotlib geopandas
我已经绘制了一个圆形图。但是颜色栏不能正确显示。
这是我正在使用的数据框:
这是我的代码:
ax=new_df.plot(figsize=(18,16), column='count', cmap='Blues', k=5, legend=True) plt.title("Number of IPs by district - Ontario") ax.set_axis_off()
这就是我所拥有的:
答案 0 :(得分:0)
问题在于“计数”列的类型为Object。因此,将其转换为数字后,就可以绘制颜色条以及圆形图。
#Converting to numeric new_df['count'] = new_df['count'].astype('int16') new_df.dtypes #Plotting ax=new_df.plot(figsize=(12,12), column='count', cmap='Blues', k=5, legend=True) plt.title("Number of IPs by district - Ontario") ax.set_axis_off()