最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

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

氣輕PyQt5 37 Qchart顯示數(shù)據(jù)點(diǎn)坐標(biāo)值 (setPointLabelsVisible)

2023-07-03 07:13 作者:氣輕  | 我要投稿

?

from PyQt5.QtGui import *

from PyQt5.QtCore import *

from PyQt5.QtWidgets import *

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

from math import ceil

import sys

?

class PyQt537(QMainWindow):

??? def __init__(self):

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

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

?

??? def initUI(self):

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

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

?

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

??????? gdpData? = [30319.98, 18809.64, 32679.87, 12820.4, 13509.15,

??????????????????? 12001.52, 22859.35, 24221.98, 20363.19, 15342.77]

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

?

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

?

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

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

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

?

?

??????? spline.setName("2018年部分城市GDP")

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

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

??????? spline.setPointLabelsVisible(True)???????????? ?# 數(shù)據(jù)點(diǎn)坐標(biāo)可視

??????? spline.setPointLabelsFormat("(@xPoint, @yPoint)")

??????? spline.setPointLabelsFont(QFont(None, 6))

??????? spline.setPointLabelsColor(Qt.darkBlue)

???????????????

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

?

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

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

?

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

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

??????? spline.attachAxis(axis_x)

?

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

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

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

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

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

??????? spline.attachAxis(axis_y)

?

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

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

???????

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

?

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

?

if __name__ == '__main__':

??? app = QApplication(sys.argv)

??? window = PyQt537()

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

?

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


氣輕PyQt5 37 Qchart顯示數(shù)據(jù)點(diǎn)坐標(biāo)值 (setPointLabelsVisible)的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
楚雄市| 化德县| 南丰县| 贵德县| 肇源县| 德格县| 年辖:市辖区| 昌图县| 洪洞县| 芦溪县| 长沙市| 盘锦市| 宜良县| 偏关县| 常山县| 峨山| 武穴市| 台江县| 阿坝| 苏尼特左旗| 叶城县| 松阳县| 岫岩| 郸城县| 麦盖提县| 安福县| 开封县| 都兰县| 吉林市| 岳西县| 通辽市| 郑州市| 临高县| 祁门县| 根河市| 广南县| 云霄县| 太保市| 城固县| 侯马市| 巴彦淖尔市|