| 网站首页 | 业界新闻 | 小组 | 交易 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛

问题点数：0 回复次数：0

```# -*- coding: utf-8 -*-
"""
Created on Sun Sep 29 17:56:15 2019
@author: Jie Zhang，微信公众号【EasyShu】，本代码源自《Python数据可视化之美》
"""
import numpy as np
from matplotlib import cm,colors
from matplotlib import pyplot as plt
from matplotlib.pyplot import figure, show, rc
import pandas as pd

plt.rcParams["patch.force_edgecolor"] =True

mydata=pd.DataFrame(dict(day=["北京","上海","广东","安徽","河南","江苏","重庆","云南","四川","江西","湖北",
"河北","西藏","浙江","黑龙江","吉林","辽宁","天津","新疆","山东","海南","广西",
"贵州","宁夏","陕西","青海","福建","内蒙古","甘肃"],
月最低工资标准=[10, 60, 50, 20,10,90,30,10,23,34,50,10, 60, 50, 20,10,90,30,10,23,34,50,40,50,60,70,80,90,100],
小时最低工资标准=[20,50, 10, 10,30,60,50,60, 50, 20,10,30, 50, 20, 40,10,40,50,40,90,80,120,34,50,10, 60, 50, 20,10]))

n_row = mydata.shape[0]
n_col= mydata.shape[1]
angle = np.arange(0,2*np.pi,2*np.pi/n_row)
#绘制的数据

cmap=cm.get_cmap('Reds',n_col)
color=[colors.rgb2hex(cmap(i)[:3]) for i in range(cmap.N) ]

fig = figure(figsize=(8,8),dpi =90)
ax = fig.add_axes([0.1, 0.1, 0.8, 0.8], polar=True)

#方法用于设置角度偏离,参数值为弧度值数值
ax.set_theta_offset(np.pi/2)
#当set_theta_direction的参数值为1,'counterclockwise'或者是'anticlockwise'的时候，正方向为逆时针；
#当set_theta_direction的参数值为-1或者是'clockwise'的时候，正方向为顺时针；
ax.set_theta_direction(1)
#方法用于设置极径标签显示位置,参数为标签所要显示在的角度
ax.set_rlabel_position(360)

barwidth1=0.07
barwidth2=0.07

plt.legend(loc="center",bbox_to_anchor=(1.2, 0, 0, 1))

plt.ylim(-150,140)
plt.xticks(angle+2*np.pi/n_row/4,labels=mydata.day,size=12)
plt.yticks([],verticalalignment='center',horizontalalignment='left')

ax.grid(False)
#plt.grid(which='major',axis ="x", linestyle='-', linewidth='0.5', color='gray',alpha=0.5)
#plt.grid(which='major',axis ="y", linestyle='-', linewidth='0.5', color='gray',alpha=0.5)

#fig.savefig('径向柱图2.pdf')

```

• 1
• 1/1页
• 1