雷达图

xiaoxiao2021-02-28  4

# -*- coding: utf-8 -*- """ Module implementing MainWindow. """ from PyQt5 import QtWidgets from PyQt5.QtCore import pyqtSlot from PyQt5.QtWidgets import QMainWindow, QTableWidgetItem from Ui_CEMS import Ui_MainWindow import matplotlib as mpl import numpy as np import matplotlib.pyplot as plt plt.style.use('ggplot') mpl.rcParams['font.family']='STSong'#解决matplotlib标签汉字显示方框的错误 #----连接数据库 import sqlite3 #cnn=sqlite3.connect("ce_info.db") #cur=cnn.cursor() #sql="select * from t_profit" #cur.execute(sql) #results=cur.fetchall() #cur.close() #cnn.close() class MainWindow(QMainWindow, Ui_MainWindow): """ Class documentation goes here. """ def __init__(self, parent=None): """ Constructor @param parent reference to the parent widget @type QWidget """ super(MainWindow, self).__init__(parent) self.setupUi(self) @pyqtSlot() def on_pushBtn_search_clicked(self): """ Slot documentation goes here. """ # TODO: not implemented yet self.tableWidget_antecedent.setRowCount(5) self.tableWidget_antecedent.setColumnCount(6) a=QTableWidgetItem(str("ss")) self.tableWidget_antecedent.setItem(0, 0, a) print("aaa") self.tableWidget_ability.setRowCount(3) self.tableWidget_ability.setColumnCount(5) #-----------绘图 ability_size=6 ability_label=[u"经营能力","管理能力","政治评价", "管理规模", "创新能力","上升潜力"] ax1=plt.subplot(2, 2, 1, projection='polar') ax2=plt.subplot(2, 2, 2, projection='polar') ax3=plt.subplot(2, 2, 3, projection='polar') ax4=plt.subplot(2, 2, 4, projection='polar') em={ "A":np.random.randint(size=ability_size, low=40, high=99), "B":np.random.randint(size=ability_size, low=40, high=99), "C":np.random.randint(size=ability_size, low=40, high=99), "D":np.random.randint(size=ability_size, low=40, high=99), } theta=np.linspace(0, 2*np.pi, 6, endpoint=False) theta=np.append(theta, theta[0]) em["A"]=np.append(em["A"], em["A"][0]) ax1.plot(theta, em["A"], 'r') ax1.fill(theta, em["A"], 'r', alpha=0.3) ax1.set_xticks(theta) ax1.set_xticklabels(ability_label)#, y=-0.03值表示标签距圆距离 ax1.set_title("同品牌经营力", size=12, color='r') ax1.set_yticks([20, 40, 60, 80, 100]) # from matplotlib.font_manager import FontProperties#变换字体,也可使用导入matplotlib字体库 # font=FontProperties(fname=r'c:\windows\fonts\simsu.ttc') # ax1.set_title("同品牌经营力", fontproperties=font, color='r', size=20) em["B"]=np.append(em["B"], em["B"][0]) ax2.plot(theta, em["B"], 'r') ax2.fill(theta, em["B"], 'r', alpha=0.3) ax2.set_xticks(theta) ax2.set_xticklabels(ability_label)#, y=-0.03值表示标签距圆距离 ax2.set_title("同区域经营力", size=12, color='r') em["C"]=np.append(em["C"], em["C"][0]) ax3.plot(theta, em["C"], 'r') ax3.fill(theta, em["C"], 'r', alpha=0.3) ax3.set_xticks(theta) ax3.set_xticklabels(ability_label)#, y=-0.03值表示标签距圆距离 ax3.set_title("集团内经营力", size=12, color='r') em["D"]=np.append(em["D"], em["D"][0]) ax3.plot(theta, em["D"], 'green') ax3.fill(theta, em["D"], 'green', alpha=0.3) ax3.set_xticks(theta) ax3.set_xticklabels(ability_label)#, y=-0.03值表示标签距圆距离 ax3.set_title("集团外经营力", size=12, color='r') plt.show( ) print(em, theta) if __name__ == "__main__": import sys app = QtWidgets.QApplication(sys.argv) ui = MainWindow() ui.show() sys.exit(app.exec_())
转载请注明原文地址: https://www.6miu.com/read-2650262.html

最新回复(0)