五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

氣輕PyQt5 41 QChart水平柱狀圖(QBarSet)

2023-07-24 07:15 作者:氣輕  | 我要投稿

?

from PyQt5.QtGui import *

from PyQt5.QtCore import *

from PyQt5.QtWidgets import *

from PyQt5.QtChart import QHorizontalBarSeries, QBarSet, QChart, QChartView, QValueAxis, QBarCategoryAxis

from math import ceil

import numpy as np

import sys

?

class PyQt541(QMainWindow):

??? def __init__(self):

??????? super().__init__()

??????? self.initUI()

?

??? def initUI(self):

??????? self.setWindowTitle("chart")

??????? self.resize(600, 400)?????????????????????????? # 設(shè)置窗口大小

?

??????? cityName = ['北京', '天津', '上海', '南京', '杭州', '青島', '廣州', '深圳', '重慶', '成都']

??????? yearData = ['2018', '2017'];

??????? gdpData=np.array([[30319.98, 28014.94],

????????????????????????? [18809.64, 18549.19],

????????????????????????? [32679.87, 30632.99],

????????????????????????? [12820.40, 11715.10],

????????????????????????? [13509.15, 12603.36],

????????????????????????? [12001.52, 11037.28],

??????????????? ??????????[22859.35, 21503.15],

????????????????????????? [24221.98, 22490.06],

????????????????????????? [20363.19, 19424.73],

????????????????????????? [15342.77, 13889.39]])

??????? MaxGDP = ceil(gdpData.max()/9)*10

?

??????? chart = QChart()??????????? ????????????????????# 圖表組件

??????? pen = QPen(QColor('#8B000'),3)????????????????? # 曲線顏色

??????? chart.setTitle("部分城市GDP")

??????? barSeries = QHorizontalBarSeries()

?

??????? gdp = list(gdpData.transpose())

??????? barDict = dict.fromkeys(yearData)

????? ??for i, value in enumerate(yearData):

??????????? barDict[value] = QBarSet(value)

??????????? barDict[value].append(gdp[i])

??????????? barSeries.append(barDict[value])

?

??????? chart.addSeries(barSeries)

?

??????? axis_x = QValueAxis()

??????? axis_x.setLabelFormat("%d")

??????? axis_x.setRange(0, MaxGDP)

??????? axis_x.setTitleText("億元")

??????? axis_x.setLinePen(pen)????????????????????????? # 設(shè)置X軸顏色和寬度

?

??????? axis_y = QBarCategoryAxis()???????????????????? # 柱狀圖坐標(biāo)

??????? axis_y.append(cityName)

?

??????? axis_y.setTitleText("城市")

??????? axis_y.setLinePen(pen)????????????????????????? # 設(shè)置Y軸顏色和寬度

??????? chart.addAxis(axis_x, Qt.AlignBottom)

?

??????? chart.addAxis(axis_y, Qt.AlignLeft)

?

??????? chartView = QChartView()??????????????????????? # 視圖組件

??????? chartView.setChart(chart)?????????????????????? # 顯示chart

??????? chartView.setRenderHint(QPainter.Antialiasing)? # 增加抗鋸齒

???????

??????? self.setCentralWidget(chartView)

?

??????? self.show()

?

if __name__ == '__main__':

??? app = QApplication(sys.argv)

??? window = PyQt541()

??? sys.exit(app.exec())

?

執(zhí)行結(jié)果


氣輕PyQt5 41 QChart水平柱狀圖(QBarSet)的評論 (共 條)

分享到微博請遵守國家法律
尼木县| 鹰潭市| 车致| 陇南市| 永安市| 昌乐县| 望城县| 巧家县| 游戏| 高唐县| 江孜县| 内丘县| 嘉兴市| 阿巴嘎旗| 石狮市| 原平市| 龙江县| 台东市| 满城县| 新巴尔虎右旗| 枣强县| 清流县| 兴业县| 大方县| 阿瓦提县| 大同市| 南投市| 昌平区| 桃园市| 察隅县| 炉霍县| 蓝山县| 石城县| 剑川县| 洞口县| 桂东县| 翁源县| 龙井市| 石柱| 清涧县| 宜城市|