国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

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

氣輕PyQt5 42 QChart動(dòng)畫(huà)模式(Animation)

2023-07-27 07:45 作者:氣輕  | 我要投稿

?

from PyQt5.QtGui import *

from PyQt5.QtCore import *

from PyQt5.QtWidgets import *

from PyQt5.QtChart import QSplineSeries, QLineSeries, QChart, QChartView, QValueAxis, QBarCategoryAxis

import numpy as np

from math import ceil, floor

import sys

?

class PyQt538(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

??????? MinGDP = floor(gdpData.min()/10)*8

?

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

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

?

??????? chart.setAnimationOptions(QChart.SeriesAnimations)

??????? chart.setAnimationDuration(500)???????????????? # 動(dòng)畫(huà)持續(xù)時(shí)間msecs

??????? chart.setAnimationEasingCurve(QEasingCurve.OutCirc)

??????? chart.legend().show()

?

??????? spline18 = self.addSpline(gdpData[:,0],'#FFA500','2018');

??????? spline17 = self.addSpline(gdpData[:,1],'#00A5FF','2017');

?

??????? chart.addSeries(spline18)?????????????????????? # 添加Series

??????? chart.addSeries(spline17)?????????????????????? # 添加Series

?

??????? penx = QPen(QColor(0x1E90FF))?????????????????? # X軸顏色

??????? penx.setWidth(2)??????????????????????????????? # X軸寬度

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

??????? axis_x.append(cityName)

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

??????? axis_x.setRange(cityName[0], cityName[-1])

?

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

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

??????? spline18.attachAxis(axis_x)

??????? spline17.attachAxis(axis_x)

?

??????? peny = QPen(QColor(0x8B7500))?????????????????? # Y軸顏色

??????? peny.setWidth(2)??????????????????????????????? # Y軸寬度

??????? axis_y = QValueAxis()

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

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

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

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

??????? axis_y.setRange(MinGDP, MaxGDP)

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

??????? spline18.attachAxis(axis_y)

??????? spline17.attachAxis(axis_y)

?

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

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

???????

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

?

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

?

??? def addSpline(self,points,color,lineName):

?

??????? pens = QPen(QColor(color),3)??????????????????? # 曲線顏色

??????? spline = QSplineSeries()??????????????????????? # 樣條曲線

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

??????????? spline.append(i, value)

?

??????? spline.setName(lineName)

??????? spline.setColor(Qt.blue)

??????? spline.setPointsVisible(True)?????????????????? # 數(shù)據(jù)點(diǎn)可視

??????? spline.setPen(pens)???????????????????????????? # 設(shè)置曲線顏色和寬度

?

??????? return spline

?

if __name__ == '__main__':

??? app = QApplication(sys.argv)

??? window = PyQt538()

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


氣輕PyQt5 42 QChart動(dòng)畫(huà)模式(Animation)的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
龙口市| 开江县| 天柱县| 丰顺县| 驻马店市| 佛山市| 准格尔旗| 焦作市| 招远市| 南昌市| 台北市| 城固县| 广州市| 邹城市| 喀什市| 梓潼县| 石台县| 藁城市| 都江堰市| 郁南县| 庆安县| 手机| 潼南县| 泉州市| 玛纳斯县| 兴城市| 仲巴县| 凤台县| 宁强县| 即墨市| 库尔勒市| 晋江市| 南昌市| 云梦县| 宁夏| 当阳市| 涟水县| 什邡市| 新平| 徐州市| 怀化市|