欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

PyQt5+QtChart實(shí)現(xiàn)繪制極坐標(biāo)圖

 更新時(shí)間:2022年12月16日 09:56:04   作者:SongYuLong的博客  
QChart是一個(gè)QGraphicScene中可以顯示的QGraphicsWidget。本文將利用QtChart實(shí)現(xiàn)極坐標(biāo)圖的繪制,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以了解一下

散點(diǎn)極坐標(biāo)圖

import sys
import random
import math

from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
from PyQt5.QtCore import Qt
from PyQt5.QtChart import QScatterSeries, QPolarChart, QChart, QChartView, QValueAxis

class MyPolarWindow(QWidget):
    def __init__(self, parent=None):
        super(MyPolarWindow, self).__init__(parent)

        # 創(chuàng)建圖表
        polarChart = QPolarChart()
        chartView = QChartView()

        # 創(chuàng)建Series
        scatterSeries = QScatterSeries()

        # 添加數(shù)據(jù)
        for value in range(1, 50):
            scatterSeries.append(value, random.random()*10)
            #scatterSeries.append(QPointF(value, random.random()*10))
        
        scatterSeries.setMarkerSize(10)
        scatterSeries.setColor(Qt.red)
        scatterSeries.setBorderColor(Qt.yellow)
        scatterSeries.setMarkerShape(QScatterSeries.MarkerShapeCircle)  # 圓形標(biāo)記
        # scatterSeries.setMarkerShape(QScatterSeries.MarkerShapeRectangle) # 方形標(biāo)記        
        scatterSeries.setName("星位圖")

        polarChart.addSeries(scatterSeries)
        polarChart.setContentsMargins(0, 0, 0, 0)
        polarChart.setTheme(QChart.ChartThemeBlueCerulean)
        # polarChart.createDefaultAxes()


        # 設(shè)置 角向軸
        angularAxis = QValueAxis()
        angularAxis.setTickCount(9)
        angularAxis.setLabelFormat("%.2f")
        angularAxis.setShadesVisible(True)
        angularAxis.setShadesBrush(QBrush(QColor(230, 230, 255)))
        polarChart.addAxis(angularAxis, QPolarChart.PolarOrientationAngular)
        angularAxis.setRange(0, 20) # 必須設(shè)置范圍,否則圖表無法顯示

        # 設(shè)置 徑向軸
        radialAxis = QValueAxis()
        radialAxis.setTickCount(5)
        radialAxis.setLabelFormat("%d")
        polarChart.addAxis(radialAxis, QPolarChart.PolarOrientationRadial)
        radialAxis.setRange(0, 10)
        
        chartView.setChart(polarChart)
        chartView.setFocusPolicy(Qt.NoFocus)
        chartView.setRenderHint(QPainter.Antialiasing)

        vbox = QVBoxLayout()
        vbox.addWidget(chartView)
        self.setLayout(vbox)

        # polarChart.zoomOut()
        # polarChart.zoomIn()
        # polarChart.scroll(-1.0, 0)
        # polarChart.scroll(1.0, 0)
        # polarChart.scroll(0, 1.0)
        # polarChart.scroll(0, -1.0)

if __name__ == "__main__":
    app = QApplication(sys.argv)
    win = MyPolarWindow()
    win.show()
    sys.exit(app.exec_())

折線極坐標(biāo)圖

import sys
import random
import math

from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
from PyQt5.QtCore import Qt
from PyQt5.QtChart import QLineSeries, QPolarChart, QChart, QChartView, QValueAxis

class MyPolarWindow(QWidget):
    def __init__(self, parent=None):
        super(MyPolarWindow, self).__init__(parent)
        self.setWindowTitle("散點(diǎn)極坐標(biāo)圖")
        # 創(chuàng)建圖表
        polarChart = QPolarChart()
        chartView = QChartView()

        # 創(chuàng)建Series
        scatterSeries = QLineSeries()

        # 添加數(shù)據(jù)
        for value in range(1, 50):
            scatterSeries.append(value, random.random()*10)
            #scatterSeries.append(QPointF(value, random.random()*10))
        

        scatterSeries.setName("折線極坐標(biāo)圖")

        polarChart.addSeries(scatterSeries)
        polarChart.setContentsMargins(0, 0, 0, 0)
        polarChart.setTheme(QChart.ChartThemeBlueCerulean)
        # polarChart.createDefaultAxes()


        # 設(shè)置 角向軸
        angularAxis = QValueAxis()
        angularAxis.setTickCount(9)
        angularAxis.setLabelFormat("%.2f")
        angularAxis.setShadesVisible(True)
        angularAxis.setShadesBrush(QBrush(QColor(230, 230, 255)))
        polarChart.addAxis(angularAxis, QPolarChart.PolarOrientationAngular)
        angularAxis.setRange(0, 20) # 必須設(shè)置范圍,否則圖表無法顯示

        # 設(shè)置 徑向軸
        radialAxis = QValueAxis()
        radialAxis.setTickCount(5)
        radialAxis.setLabelFormat("%d")
        polarChart.addAxis(radialAxis, QPolarChart.PolarOrientationRadial)
        radialAxis.setRange(0, 10)
        
        chartView.setChart(polarChart)
        chartView.setFocusPolicy(Qt.NoFocus)
        chartView.setRenderHint(QPainter.Antialiasing)

        vbox = QVBoxLayout()
        vbox.addWidget(chartView)
        self.setLayout(vbox)

if __name__ == "__main__":
    app = QApplication(sys.argv)
    win = MyPolarWindow()
    win.show()
    sys.exit(app.exec_())

曲線極坐標(biāo)圖

import sys
import random
import math

from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
from PyQt5.QtCore import Qt
from PyQt5.QtChart import QSplineSeries, QPolarChart, QChart, QChartView, QValueAxis

class MyPolarWindow(QWidget):
    def __init__(self, parent=None):
        super(MyPolarWindow, self).__init__(parent)
        self.setWindowTitle("散點(diǎn)極坐標(biāo)圖")
        # 創(chuàng)建圖表
        polarChart = QPolarChart()
        chartView = QChartView()

        # 創(chuàng)建Series
        scatterSeries = QSplineSeries()

        # 添加數(shù)據(jù)
        for value in range(1, 50):
            scatterSeries.append(value, random.random()*10)
            #scatterSeries.append(QPointF(value, random.random()*10))
        

        scatterSeries.setName("曲線極坐標(biāo)圖")

        polarChart.addSeries(scatterSeries)
        polarChart.setContentsMargins(0, 0, 0, 0)
        polarChart.setTheme(QChart.ChartThemeBlueCerulean)
        # polarChart.createDefaultAxes()


        # 設(shè)置 角向軸
        angularAxis = QValueAxis()
        angularAxis.setTickCount(9)
        angularAxis.setLabelFormat("%.2f")
        angularAxis.setShadesVisible(True)
        angularAxis.setShadesBrush(QBrush(QColor(230, 230, 255)))
        polarChart.addAxis(angularAxis, QPolarChart.PolarOrientationAngular)
        angularAxis.setRange(0, 20) # 必須設(shè)置范圍,否則圖表無法顯示

        # 設(shè)置 徑向軸
        radialAxis = QValueAxis()
        radialAxis.setTickCount(5)
        radialAxis.setLabelFormat("%d")
        polarChart.addAxis(radialAxis, QPolarChart.PolarOrientationRadial)
        radialAxis.setRange(0, 10)
        
        chartView.setChart(polarChart)
        chartView.setFocusPolicy(Qt.NoFocus)
        chartView.setRenderHint(QPainter.Antialiasing)

        vbox = QVBoxLayout()
        vbox.addWidget(chartView)
        self.setLayout(vbox)

if __name__ == "__main__":
    app = QApplication(sys.argv)
    win = MyPolarWindow()
    win.show()
    sys.exit(app.exec_())

區(qū)域極坐標(biāo)圖

import sys
import random
import math

from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
from PyQt5.QtCore import Qt
from PyQt5.QtChart import QLineSeries, QAreaSeries, QPolarChart, QChart, QChartView, QValueAxis

class MyPolarWindow(QWidget):
    def __init__(self, parent=None):
        super(MyPolarWindow, self).__init__(parent)
        self.setWindowTitle("區(qū)域極坐標(biāo)圖")
        # 創(chuàng)建圖表
        polarChart = QPolarChart()
        chartView = QChartView()

         # 創(chuàng)建Series
        series0 = QLineSeries()
        series1 = QLineSeries()

        # 添加數(shù)據(jù)
        series0 << QPointF(1, 5) << QPointF(3, 7) << QPointF(7, 6) << QPointF(9, 7) \
        << QPointF(12, 6) << QPointF(16, 7) << QPointF(18, 5)
        series1 << QPointF(1, 3) << QPointF(3, 4) << QPointF(7, 3) << QPointF(8, 2) \
        << QPointF(12, 3) << QPointF(16, 4) << QPointF(18, 3)

        # 創(chuàng)建區(qū)域圖
        area = QAreaSeries(series0, series1)
        area.setName("折線極坐標(biāo)圖")

        polarChart.addSeries(area)
        polarChart.setContentsMargins(0, 0, 0, 0)
        polarChart.setTheme(QChart.ChartThemeBlueCerulean)
        # polarChart.createDefaultAxes()


        # 設(shè)置 角向軸
        angularAxis = QValueAxis()
        angularAxis.setTickCount(9)
        angularAxis.setLabelFormat("%.2f")
        angularAxis.setShadesVisible(True)
        angularAxis.setShadesBrush(QBrush(QColor(230, 230, 255)))
        polarChart.addAxis(angularAxis, QPolarChart.PolarOrientationAngular)
        angularAxis.setRange(0, 50) # 必須設(shè)置范圍,否則圖表無法顯示

        # 設(shè)置 徑向軸
        radialAxis = QValueAxis()
        radialAxis.setTickCount(5)
        radialAxis.setLabelFormat("%d")
        polarChart.addAxis(radialAxis, QPolarChart.PolarOrientationRadial)
        radialAxis.setRange(0, 20)
        
        chartView.setChart(polarChart)
        chartView.setFocusPolicy(Qt.NoFocus)
        chartView.setRenderHint(QPainter.Antialiasing)

        vbox = QVBoxLayout()
        vbox.addWidget(chartView)
        self.setLayout(vbox)

if __name__ == "__main__":
    app = QApplication(sys.argv)
    win = MyPolarWindow()
    win.show()
    sys.exit(app.exec_())

以上就是PyQt5+QtChart實(shí)現(xiàn)繪制極坐標(biāo)圖的詳細(xì)內(nèi)容,更多關(guān)于PyQt5 QtChart極坐標(biāo)圖的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • Python使用Selenium+BeautifulSoup爬取淘寶搜索頁

    Python使用Selenium+BeautifulSoup爬取淘寶搜索頁

    這篇文章主要為大家詳細(xì)介紹了Python使用Selenium+BeautifulSoup爬取淘寶搜索頁,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-02-02
  • 在Linux命令行終端中使用python的簡單方法(推薦)

    在Linux命令行終端中使用python的簡單方法(推薦)

    下面小編就為大家?guī)硪黄贚inux命令行終端中使用python的簡單方法(推薦)。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-01-01
  • Python中如何創(chuàng)建和運(yùn)行異步任務(wù)詳解

    Python中如何創(chuàng)建和運(yùn)行異步任務(wù)詳解

    這篇文章主要為大家介紹了Python中如何創(chuàng)建和運(yùn)行異步任務(wù)詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-03-03
  • 一文詳解NumPy分割與搜索數(shù)組

    一文詳解NumPy分割與搜索數(shù)組

    NumPy 提供了 np.array_split() 函數(shù)來分割數(shù)組,將一個(gè)數(shù)組拆分成多個(gè)較小的子數(shù)組和提供了多種方法來搜索數(shù)組中的元素,并返回匹配項(xiàng)的索引,本文將給大家詳細(xì)介紹NumPy分割與搜索數(shù)組,需要的朋友可以參考下
    2024-05-05
  • 新版selenium4.0 + Python使用詳解

    新版selenium4.0 + Python使用詳解

    本文主要介紹了新版selenium4.0 + Python使用詳解,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2022-07-07
  • Python提高運(yùn)行速度工具之Pandarallel的使用教程

    Python提高運(yùn)行速度工具之Pandarallel的使用教程

    為了提高運(yùn)行速度,我們一般會(huì)采用多進(jìn)程的方式。而常見的方案對(duì)于普通python玩家來說都不是特別友好,怎樣才能算作一個(gè)友好的并行處理方案?本文就來和大家講講pandarallel的使用
    2022-09-09
  • pytorch關(guān)于卷積操作的初始化方式(kaiming_uniform_詳解)

    pytorch關(guān)于卷積操作的初始化方式(kaiming_uniform_詳解)

    這篇文章主要介紹了pytorch關(guān)于卷積操作的初始化方式(kaiming_uniform_詳解),具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-09-09
  • Python深度學(xué)習(xí)pytorch神經(jīng)網(wǎng)絡(luò)Dropout應(yīng)用詳解解

    Python深度學(xué)習(xí)pytorch神經(jīng)網(wǎng)絡(luò)Dropout應(yīng)用詳解解

    這篇文章主要為大家介紹了Python深度學(xué)習(xí)中關(guān)于pytorch神經(jīng)網(wǎng)絡(luò)Dropout的應(yīng)用詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步
    2021-10-10
  • Python中文字符串截取問題

    Python中文字符串截取問題

    web應(yīng)用難免會(huì)截取字符串的需求,Python中截取英文很容易,但是截取utf-8的中文機(jī)會(huì)截取一半導(dǎo)致一些不是亂碼的亂碼.其實(shí)utf8截取很簡單,這里記下來分享給大家
    2015-06-06
  • Python腳本完成post接口測試的實(shí)例

    Python腳本完成post接口測試的實(shí)例

    今天小編就為大家分享一篇Python腳本完成post接口測試的實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2018-12-12

最新評(píng)論