Skip to content

Commit

Permalink
Bugfixes:
Browse files Browse the repository at this point in the history
  - ArrowItem auto range now works correctly
  - Dock drag/drop fixed on PySide
  - Made padding behavior consistent across ViewBox methods
  - Fixed MeshData / python2.6 incompatibility
  - Fixed ScatterPlotItem.setSize and .setPointData
  - Workaround for PySide bug; GradientEditor fixed
  - Prefer initially selecting PlotItem rather then ViewBox when exporting
  - Fixed python3 import error with flowcharts

Cleaned up examples, made code editable from example loader
Minor documentation updates
  • Loading branch information
Luke Campagnola committed Feb 25, 2013
2 parents 2e79185 + 4cf9ef7 commit 03683a5
Show file tree
Hide file tree
Showing 80 changed files with 597 additions and 202 deletions.
2 changes: 1 addition & 1 deletion doc/source/how_to_use.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Pyqtgraph makes it very easy to visualize data from the command line. Observe::
import pyqtgraph as pg
pg.plot(data) # data can be a list of values or a numpy array

The example above would open a window displaying a line plot of the data given. The call to :func:`pg.plot <pyqtgraph.plot>` returns a handle to the :class:`plot widget <pyqtgraph.PlotWidget>` that is created, allowing more data to be added to the same window.
The example above would open a window displaying a line plot of the data given. The call to :func:`pg.plot <pyqtgraph.plot>` returns a handle to the :class:`plot widget <pyqtgraph.PlotWidget>` that is created, allowing more data to be added to the same window. **Note:** interactive plotting from the python prompt is only available with PyQt; PySide does not run the Qt event loop while the interactive prompt is running. If you wish to use pyqtgraph interactively with PySide, see the 'console' :ref:`example <examples>`.

Further examples::
Expand Down
10 changes: 8 additions & 2 deletions doc/source/qtcrashcourse.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ Signals, Slots, and Events

[ to be continued.. please post a request on the pyqtgraph forum if you'd like to read more ]

Qt detects and reacts to user interaction by executing its *event loop*.

- what happens in the event loop?
- when do I need to use QApplication.exec_() ?
- what control do I have over event loop execution? (QApplication.processEvents)


GraphicsView and GraphicsItems
------------------------------
Expand All @@ -79,8 +85,8 @@ Mouse and Keyboard Input
------------------------


QTimer, the Event Loop, and Multi-Threading
-------------------------------------------
QTimer, Multi-Threading
-----------------------


Multi-threading vs Multi-processing in Qt
Expand Down
14 changes: 8 additions & 6 deletions examples/Arrow.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# -*- coding: utf-8 -*-
"""
Display an animated arrowhead following a curve.
This example uses the CurveArrow class, which is a combination
of ArrowItem and CurvePoint.
## Display an animated arrowhead following a curve.
## This example uses the CurveArrow class, which is a combination
## of ArrowItem and CurvePoint.
##
## To place a static arrow anywhere in a scene, use ArrowItem.
## To attach other types of item to a curve, use CurvePoint.
To place a static arrow anywhere in a scene, use ArrowItem.
To attach other types of item to a curve, use CurvePoint.
"""

import initExample ## Add path to library (just for examples; you do not need this)

Expand All @@ -21,6 +22,7 @@
w.show()
w.resize(400,600)
w.setCentralWidget(cw)
w.setWindowTitle('pyqtgraph example: Arrow')

p = cw.addPlot(row=0, col=0)
p2 = cw.addPlot(row=1, col=0)
Expand Down
17 changes: 11 additions & 6 deletions examples/CLIexample.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
"""
Display a plot and an image with minimal setup.
pg.plot() and pg.image() are indended to be used from an interactive prompt
to allow easy data inspection (but note that PySide unfortunately does not
call the Qt event loop while the interactive prompt is running, in this case
it is necessary to call QApplication.exec_() to make the windows appear).
"""
import initExample ## Add path to library (just for examples; you do not need this)

from pyqtgraph.Qt import QtGui, QtCore

import numpy as np
import pyqtgraph as pg

app = QtGui.QApplication([])


data = np.random.normal(size=1000)
pg.plot(data, title="Simplest possible plotting example")

data = np.random.normal(size=(500,500))
pg.show(data, title="Simplest possible image example")
pg.image(data, title="Simplest possible image example")


## Start Qt event loop unless running in interactive mode or using pyside.
if __name__ == '__main__':
import sys
if sys.flags.interactive != 1 or not hasattr(QtCore, 'PYQT_VERSION'):
app.exec_()
pg.QtGui.QApplication.exec_()
6 changes: 4 additions & 2 deletions examples/ColorButton.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# -*- coding: utf-8 -*-
import initExample ## Add path to library (just for examples; you do not need this)

"""
Simple example demonstrating a button which displays a colored rectangle
and allows the user to select a new color by clicking on the button.
"""

import initExample ## Add path to library (just for examples; you do not need this)


import pyqtgraph as pg
from pyqtgraph.Qt import QtCore, QtGui
import numpy as np
Expand All @@ -15,6 +16,7 @@
btn = pg.ColorButton()
win.setCentralWidget(btn)
win.show()
win.setWindowTitle('pyqtgraph example: ColorButton')

def change(btn):
print("change", btn.color())
Expand Down
7 changes: 7 additions & 0 deletions examples/ConsoleWidget.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# -*- coding: utf-8 -*-
"""
ConsoleWidget is used to allow execution of user-supplied python commands
in an application. It also includes a command history and functionality for trapping
and inspecting stack traces.
"""
import initExample ## Add path to library (just for examples; you do not need this)

import pyqtgraph as pg
Expand All @@ -21,6 +27,7 @@
"""
c = pyqtgraph.console.ConsoleWidget(namespace=namespace, text=text)
c.show()
c.setWindowTitle('pyqtgraph example: ConsoleWidget')

## Start Qt event loop unless running in interactive mode or using pyside.
if __name__ == '__main__':
Expand Down
9 changes: 9 additions & 0 deletions examples/DataSlicing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# -*- coding: utf-8 -*-
"""
Demonstrate a simple data-slicing task: given 3D data (displayed at top), select
a 2D plane and interpolate data along that plane to generate a slice image
(displayed at bottom).
"""

## Add path to library (just for examples; you do not need this)
import initExample

Expand All @@ -12,6 +20,7 @@
## Create window with two ImageView widgets
win = QtGui.QMainWindow()
win.resize(800,800)
win.setWindowTitle('pyqtgraph example: DataSlicing')
cw = QtGui.QWidget()
win.setCentralWidget(cw)
l = QtGui.QGridLayout()
Expand Down
3 changes: 1 addition & 2 deletions examples/DataTreeWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
Simple use of DataTreeWidget to display a structure of nested dicts, lists, and arrays
"""



import initExample ## Add path to library (just for examples; you do not need this)

import pyqtgraph as pg
Expand All @@ -26,6 +24,7 @@

tree = pg.DataTreeWidget(data=d)
tree.show()
tree.setWindowTitle('pyqtgraph example: DataTreeWidget')
tree.resize(600,600)


Expand Down
7 changes: 7 additions & 0 deletions examples/Draw.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# -*- coding: utf-8 -*-
"""
Demonstrate ability of ImageItem to be used as a canvas for painting with
the mouse.
"""

import initExample ## Add path to library (just for examples; you do not need this)


Expand All @@ -12,6 +18,7 @@
w = pg.GraphicsView()
w.show()
w.resize(800,800)
w.setWindowTitle('pyqtgraph example: Draw')

view = pg.ViewBox()
w.setCentralItem(view)
Expand Down
1 change: 1 addition & 0 deletions examples/ErrorBarItem.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
bottom = np.linspace(2, 0.5, 10)

plt = pg.plot()
plt.setWindowTitle('pyqtgraph example: ErrorBarItem')
err = pg.ErrorBarItem(x=x, y=y, top=top, bottom=bottom, beam=0.5)
plt.addItem(err)
plt.plot(x, y, symbol='o', pen={'color': 0.8, 'width': 2})
Expand Down
1 change: 1 addition & 0 deletions examples/Flowchart.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

## Create main window with grid layout
win = QtGui.QMainWindow()
win.setWindowTitle('pyqtgraph example: Flowchart')
cw = QtGui.QWidget()
win.setCentralWidget(cw)
layout = QtGui.QGridLayout()
Expand Down
1 change: 1 addition & 0 deletions examples/FlowchartCustomNode.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

## Create main window with a grid layout inside
win = QtGui.QMainWindow()
win.setWindowTitle('pyqtgraph example: FlowchartCustomNode')
cw = QtGui.QWidget()
win.setCentralWidget(cw)
layout = QtGui.QGridLayout()
Expand Down
7 changes: 7 additions & 0 deletions examples/GLImageItem.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# -*- coding: utf-8 -*-
"""
Use GLImageItem to display image data on rectangular planes.
In this example, the image data is sampled from a volume and the image planes
placed as if they slice through the volume.
"""
## Add path to library (just for examples; you do not need this)
import initExample

Expand All @@ -12,6 +18,7 @@
w = gl.GLViewWidget()
w.opts['distance'] = 200
w.show()
w.setWindowTitle('pyqtgraph example: GLImageItem')

## create volume data set to slice three images from
shape = (100,100,70)
Expand Down
8 changes: 5 additions & 3 deletions examples/GLIsosurface.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# -*- coding: utf-8 -*-

## This example uses the isosurface function to convert a scalar field
## (a hydrogen orbital) into a mesh for 3D display.
"""
This example uses the isosurface function to convert a scalar field
(a hydrogen orbital) into a mesh for 3D display.
"""

## Add path to library (just for examples; you do not need this)
import initExample
Expand All @@ -13,6 +14,7 @@
app = QtGui.QApplication([])
w = gl.GLViewWidget()
w.show()
w.setWindowTitle('pyqtgraph example: GLIsosurface')

w.setCameraPosition(distance=40)

Expand Down
5 changes: 5 additions & 0 deletions examples/GLLinePlotItem.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# -*- coding: utf-8 -*-
"""
Demonstrate use of GLLinePlotItem to draw cross-sections of a surface.
"""
## Add path to library (just for examples; you do not need this)
import initExample

Expand All @@ -11,6 +15,7 @@
w = gl.GLViewWidget()
w.opts['distance'] = 40
w.show()
w.setWindowTitle('pyqtgraph example: GLLinePlotItem')

gx = gl.GLGridItem()
gx.rotate(90, 0, 1, 0)
Expand Down
2 changes: 1 addition & 1 deletion examples/GLMeshItem.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
app = QtGui.QApplication([])
w = gl.GLViewWidget()
w.show()

w.setWindowTitle('pyqtgraph example: GLMeshItem')
w.setCameraPosition(distance=40)

g = gl.GLGridItem()
Expand Down
6 changes: 6 additions & 0 deletions examples/GLScatterPlotItem.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# -*- coding: utf-8 -*-
"""
Demonstrates use of GLScatterPlotItem with rapidly-updating plots.
"""

## Add path to library (just for examples; you do not need this)
import initExample

Expand All @@ -10,6 +15,7 @@
w = gl.GLViewWidget()
w.opts['distance'] = 20
w.show()
w.setWindowTitle('pyqtgraph example: GLScatterPlotItem')

g = gl.GLGridItem()
w.addItem(g)
Expand Down
1 change: 1 addition & 0 deletions examples/GLSurfacePlot.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
app = QtGui.QApplication([])
w = gl.GLViewWidget()
w.show()
w.setWindowTitle('pyqtgraph example: GLSurfacePlot')
w.setCameraPosition(distance=50)

## Add a grid to the view
Expand Down
5 changes: 5 additions & 0 deletions examples/GLViewWidget.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# -*- coding: utf-8 -*-
"""
Very basic 3D graphics example; create a view widget and add a few items.
"""
## Add path to library (just for examples; you do not need this)
import initExample

Expand All @@ -9,6 +13,7 @@
w = gl.GLViewWidget()
w.opts['distance'] = 20
w.show()
w.setWindowTitle('pyqtgraph example: GLViewWidget')

ax = gl.GLAxisItem()
ax.setSize(5,5,5)
Expand Down
7 changes: 6 additions & 1 deletion examples/GLVolumeItem.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# -*- coding: utf-8 -*-
"""
Demonstrates GLVolumeItem for displaying volumetric data.
"""

## Add path to library (just for examples; you do not need this)
import initExample

Expand All @@ -9,7 +14,7 @@
w = gl.GLViewWidget()
w.opts['distance'] = 200
w.show()

w.setWindowTitle('pyqtgraph example: GLVolumeItem')

#b = gl.GLBoxItem()
#w.addItem(b)
Expand Down
5 changes: 3 additions & 2 deletions examples/GLshaders.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
"""
Demonstration of some of the shader programs included with pyqtgraph.
Demonstration of some of the shader programs included with pyqtgraph that can be
used to affect the appearance of a surface.
"""


Expand All @@ -15,7 +16,7 @@
app = QtGui.QApplication([])
w = gl.GLViewWidget()
w.show()

w.setWindowTitle('pyqtgraph example: GL Shaders')
w.setCameraPosition(distance=15, azimuth=-90)

g = gl.GLGridItem()
Expand Down
6 changes: 6 additions & 0 deletions examples/GradientWidget.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# -*- coding: utf-8 -*-
"""
Demonstrates the appearance / interactivity of GradientWidget
(without actually doing anything useful with it)
"""
import initExample ## Add path to library (just for examples; you do not need this)

import pyqtgraph as pg
Expand All @@ -10,6 +15,7 @@
app = QtGui.QApplication([])
w = QtGui.QMainWindow()
w.show()
w.setWindowTitle('pyqtgraph example: GradientWidget')
w.resize(400,400)
cw = QtGui.QWidget()
w.setCentralWidget(cw)
Expand Down
3 changes: 2 additions & 1 deletion examples/GraphItem.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
"""
Simple example of GridItem use.
Simple example of GraphItem use.
"""


Expand All @@ -11,6 +11,7 @@
import numpy as np

w = pg.GraphicsWindow()
w.setWindowTitle('pyqtgraph example: GraphItem')
v = w.addViewBox()
v.setAspectLocked()

Expand Down
Loading

0 comments on commit 03683a5

Please sign in to comment.