雷达图

# -*- 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_())

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值