[PYTHON] Draw a graph with PyQtGraph Part 1-Drawing

About PyQtGraph

Wrote here. However, I left it too much, so I repartitioned it ... Roughly summarize in the center of the code.

Part 1 up to drawing

1.png

import sys
from PySide.QtCore import *
from PySide.QtGui import *
import pyqtgraph as pg


class GraphWindow(QMainWindow):

    def __init__(self, parent = None):
        
        super(GraphWindow, self).__init__(parent)
        
        ##1 Create a PlotWidget
        pw = pg.PlotWidget()

        ##1 Set the widget in the window
        self.setCentralWidget(pw)

        ##1 Call plotItem
        p1 = pw.plotItem

        ##1 Draw a scatter plot and a line graph
        p1.addItem(pg.PlotCurveItem(x = [0, 1, 2, 3 ,4], 
                                    y = [0, 1, 2, 3 ,4]))
        p1.addItem(pg.ScatterPlotItem(x = [0, 1, 2, 3 ,4], 
                                      y = [4, 3, 2, 1, 0]))


if __name__ == '__main__':
    #Create a Qt Application
    app = QApplication(sys.argv)
    #Create and display form
    mainWin = GraphWindow()
    mainWin.show()
    #Start the main loop of Qt
    sys.exit(app.exec_())

Recommended Posts

Draw a graph with PyQtGraph Part 1-Drawing
Draw a graph with PyQtGraph Part 3-PlotWidget settings
Draw a graph with PyQtGraph Part 4-PlotItem settings
Draw a graph with PyQtGraph Part 6-Displaying a legend
Draw a graph with Julia + PyQtGraph (2)
Draw a graph with Julia + PyQtGraph (1)
Draw a graph with Julia + PyQtGraph (3)
Draw a graph with PyQtGraph Part 2--Detailed plot settings
Draw a graph with NetworkX
Draw a graph with networkx
Draw a loose graph with matplotlib
Draw a graph with pandas + XlsxWriter
Draw a graph with PySimple GUI
Draw a flat surface with a matplotlib 3d graph
Draw a graph with Japanese labels in Jupyter
How to draw a 2-axis graph with pyplot
Draw a graph by processing with Pandas groupby
[Python] Draw a directed graph with Dash Cytoscape
Draw a graph with matplotlib from a csv file
[Python] How to draw a line graph with Matplotlib
Graph drawing method with matplotlib
Graph drawing with IPython Notebook
Study math with Python: Draw a sympy (scipy) graph with matplotlib
[Visualization] I want to draw a beautiful graph with Plotly
Play with a turtle with turtle graphics (Part 1)
Draw a beautiful circle with numpy
Let's make a graph with python! !!
Make a nice graph with plotly
Easily draw a map with matplotlib.basemap
Count the maximum concatenated part of a random graph with NetworkX
[PyQt] Display a multi-axis graph with QtChart
Try drawing a normal distribution with matplotlib
[Python] Drawing a swirl pattern with turtle
Draw a heart in Ruby with PyCall
Draw a heart in Python Part 2 (SymPy)
Make a drawing quiz with kivy + PyTorch
Draw a Mandelbrot set with Brainf * ck
Try drawing a map with python + cartopy 0.18.0
Create a graph with borders removed with matplotlib
(Matplotlib) I want to draw a graph with a size specified in pixels
How to draw a bar graph that summarizes multiple series with matplotlib
Draw a graph that can be moved around with HoloViews and Bokeh
Tweet the weather forecast with a bot Part 2
How to draw a 3D graph before optimization
Draw a "breast curved surface" in a 3D graph (1)
Beautiful graph drawing with python -seaborn makes data analysis and visualization easier Part 1
Try to draw a life curve with python
Beautiful graph drawing with python -seaborn makes data analysis and visualization easier Part 2
[Python] Draw a Mickey Mouse with Turtle [Beginner]
Graph drawing with jupyter (ipython notebook) + matplotlib + vagrant
Draw a "breast curved surface" in a 3D graph (2)
I made a random number graph with Numpy
Draw multiple photos in a graph from multiple folders
[Python] Draw a Qiita tag relationship diagram with NetworkX
Try drawing a social graph using Twitter API v2
Until drawing a 3D graph in Python on windows10
How to make a shooting game with toio (Part 1)
Visualize railway line data as a graph with Cytoscape 2
Drawing a tree structure with D3.js in Jupyter Notebook
"My Graph Generation Application" by Python (PySide + PyQtGraph) Part 2
Forcibly draw something like a flowchart with Python, matplotlib