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

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

氣輕PyQt5 38 QChart坐標(biāo)軸,曲線顏色和寬度(QPen)

2023-07-05 12:58 作者:氣輕  | 我要投稿

?

用QPen可以設(shè)置坐標(biāo)軸,曲線的顏色和寬度等屬性。

?

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()??????????????????????????????? # 圖表組件

?

??????? pens = QPen(QColor(0xFFA500))?????????????????? # 曲線顏色

??????? pens.setWidth(8)??????????????????????????????? # 曲線寬度

??????? 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)

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

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

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

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

?

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

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

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

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

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

?

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

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

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

?

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

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

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

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

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

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

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

??????? 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 38 QChart坐標(biāo)軸,曲線顏色和寬度(QPen)的評論 (共 條)

分享到微博請遵守國家法律
蓬莱市| 定西市| 漯河市| 江安县| 镇江市| 龙海市| 奉化市| 安国市| 江西省| 太仆寺旗| 繁峙县| 綦江县| 吉安市| 锡林浩特市| 凤阳县| 沽源县| 邵阳市| 鄂托克前旗| 奉节县| 仲巴县| 崇信县| 五原县| 定陶县| 当涂县| 大田县| 长葛市| 拉萨市| 驻马店市| 邢台市| 南华县| 淮滨县| 丘北县| 桃源县| 正定县| 津南区| 北辰区| 湄潭县| 全南县| 崇仁县| 江油市| 新绛县|