Commit Graph

357 Commits

Author SHA1 Message Date
2xB
433b061e81
Fix TickSliderItem: Avoid ghost ticks | Improved customPlot.py code (#1459)
* Fix TickSliderItem: Avoid ghost ticks | Improved customPlot.py code

If `TickSliderItem.setTickValue` was called when a full repaint of the `TickSliderItem` was
not already scheduled, the tick was visible at the old and the new position. This could e.g. be seen
when using the autoscale button in the `customPlot.py` example.

Further, code from `customPlot.py` is improved to make use of `Tick.setVisible` instead of adding and
removing ticks based on their visibility.

* customPlot.py: Explain bool conversion

Co-authored-by: 2xB <2xB@users.noreply.github.com>
2020-11-26 22:28:03 -08:00
2xB
5adb1b9a5b
Fixes for examples\customPlot.py (#1448)
* Fix examples\customPlot.py: Not object-oriented

Copy-paste error: I referenced a specific object instead of self. Fixed.

* Fix examples\customPlot.py: Allow calling setTicks more than once

This fixes a bug where TickSliderItem is expected to return ticks.keys() but while it returns ticks.items().
Also: Minor code correction.

* Fix examples\customPlot.py: Avoid scaling differences

Consider padding of TickSliderItem for link between ViewBox and ticks

Co-authored-by: 2xB <2xB@users.noreply.github.com>
2020-11-19 10:19:32 -08:00
2xB
020b7077cb
TickSliderItem: allowRemove property added (#1442)
* TickSliderItem: allowRemove property added

Following #744, this PR suggests the addition of a property
`allowRemove` to `TickSliderItem` and therefore also to
`GradientEditorItem`. It sets the default of whether ticks can
be removed by the user and therefore contemplates `allowAdd`.

I would be interested in other opinions on this design decision,
as #744 suggests to reuse `allowAdd` for the prohibition of
tick removal.
I personally suggest this solution, since it does not change
the effect of the current API.

Fix #744

* customPlot.py: Added markers to example using TickSliderItem

* examples\GradientWidget.py: Demonstrate use of allowRemove

Co-authored-by: 2xB <2xB@users.noreply.github.com>
2020-11-16 16:18:26 -08:00
2xB
c359d5fad9
Fix ViewBox axis zoom in RectMode and examples/customPlot.py (#1443)
* Fix examples/customPlot.py: mouseDragEvent misses axis argument

Fixes #1277

* customPlot.py: Update methodolgy to disable menu

If there's an argument for this, we should use it

* customPlot.py: Show how to disable axis interaction

* Fix ViewBox: Moving axis in RectMode not implemented => use normal move mode

Grabbing an axis in RectMode leads to the zoom rectangle being displayed
in unreasonable positions. In this case, fall back to normal mode.

* customPlot.py: Only disable right-click zoom for demonstration

In cases where continuous zooming is not wished (e.g. in case of
complicated rebinning after zooming), this might come in handy
and there is no reason not to show it.

Co-authored-by: 2xB <2xB@users.noreply.github.com>
2020-11-16 14:27:40 -08:00
2xB
100c793174
Fix ExampleApp: Use pg module from directory when run without installation (#1432)
Co-authored-by: 2xB <2xB@users.noreply.github.com>
2020-11-09 14:57:01 -08:00
lidstrom83
0a7a54c3f6
Permit entry of non-finite values into float SpinBox (#1422)
* Permit nan, inf, and -inf for float SpinBox

Bounds are enforced against inf and -inf inputs, but not for nan.

* Ensure SpinBox text is updated when out-of-bounds value is entered

* Make inf and nan entry in SpinBox case-insensitive

* Make SpinBox example behave as advertised

* Make non-finite SpinBox values optionally allowed

* Python 2 compatibility
2020-10-27 21:26:05 -07:00
Ogi Moore
7e57e07068
example app now works with Qt4 and Python2 again (#1302)
* example app now workw with Qt4 and Python2 again

* Example App is now part of the test suite

* Add initExample

* No scary warning when launching examples

* Fix scary examples.__main__ warning

* Use courier new font as its on all platforms

* Remove commented out code

* Add newline

* Updated docs, example app now tested

* Non-relative import for example app

* Proper importing now
2020-10-19 11:51:12 -07:00
Carlos Pascual
23a46b5fb9
Add "left" and "right" step Modes (#1360)
* Add "lstep" and "rstep" step Modes

stepMode is currently either True or False. If it is True,
it requires the user to make len(x) = len(y)+1. This is
inconvenient because it makes it difficult to change the
stepMode on a given curve (just as one would change, e.g.,
its color).

This commit extends the current situation by introducing
two more step modes: "lstep" and "rstep", which do not require
passing an extra x value. In turn, this modes associate each
y value to either the left or the right boundary of the step.

For example, the "rstep" mode is handy when plotting "life"
digital signals in which x,y data pairs are appended as they
are read.

This commit does not modify the behaviour in case of stepMode=True

* Replace step mode names: lstep,rstep -> left,right

* Improve docs for stepMode

Reword docstring and add it to PlotDataItem class too

* Document left and right stepModes as added in v 0.12.0

TODO: confirm the exact version number to use here

* Add comments stress the need for "is True"

Some conditional statements in the code regarding stepMode are
done with "is True". This is actually required since other
possible values such as "left" also evaluate as true but should
not be caught.

* Deprecate boolean API for stepMode

Introduce stepMode="mid" as a replacement of stepMode=True,
but keeping full backwards compatibility with the old API.
Adapt docs, examples and tests accordingly.

* Raise ValueError on unsupported stepMode values

* Rename "mid" step mode to "center"

* Remove "added in 0.12.0" note

See https://github.com/pyqtgraph/pyqtgraph/pull/1360#discussion_r502746919

* Add deprecation warning when stepMode=True

Issue a DeprecationWarning if stepMode=True is being passed to the
constructor or setData() of PlotDataItem or PlotCurveItem.

Note: warnings module is imported locally so that it is esier to
remove once this check is no longer needed.

* Fix wrong syntax in last commit

Fix usage of "default" kwarg in dict.get()
2020-10-13 08:52:07 -07:00
Ogi Moore
3f7a9bb642
Merge pull request #1273 from edumur/develop
Implemented pColorMeshItem
2020-10-12 09:24:10 -07:00
Etienne Dumur
5ab0cef017 Solve artifacts issues
Add a parameter "antialiasing".
Remove profiler
Add pyqtgraph mkPen
2020-10-12 12:45:13 +02:00
Kenneth Lyons
3ea32ff447
Merge pull request #1374 from ixjlyons/test-warnings-cleanup
Test warnings cleanup
2020-09-20 14:52:49 -07:00
Kenneth Lyons
16ea8ada0c Use raw strings to get rid of DeprecationWarning
DeprecationWarning is for invalid escape sequence ('\'). Decided to use
raw strings rather than double-backslashes because the text processing
is using raw strings anwyay.
2020-09-20 13:59:44 -07:00
angulartist
58aa9306df Enhancement: [Issue/812]: just pass plotArgs keyword arguments 2020-07-19 19:16:07 +02:00
Etienne Dumur
72c03ea096 Rename PColorMesh example 2020-07-17 08:18:52 +02:00
Etienne Dumur
f8aee11190 Add PColorMeshItem example to the app 2020-07-15 10:30:41 +02:00
Etienne Dumur
98c6c56358 Make clearer the non-grid meshing of the Item 2020-06-28 15:05:29 +02:00
Etienne Dumur
919ee54b59 Add edgecolor parameter
Allow user to set the polygons edge color.
2020-06-28 14:50:44 +02:00
Etienne Dumur
d32d61a1e2 Various improvements
Make an example displaying more clearly the Item capability.
Correct few bugs in the Item class.
Improve overall comments.
2020-06-28 14:49:20 +02:00
Etienne Dumur
3cbe65d46d Correct PColorMeshItem names 2020-06-26 18:12:17 +02:00
Etienne Dumur
cbbd8287ad Remove matplotlib dependencies 2020-06-25 22:07:41 +02:00
Etienne Dumur
426a70ae60 Implemented pColorMeshItem 2020-06-23 19:59:04 +02:00
Karl Georg Bedrich
3a758cac96
NEW options for LegendItem (#395)
* NEW options for LegendItem

* * changed 'drawFrame' into 'frame'
* added **kwargs to plotItem.addLegend
* added (frame=False, colCount=2) in legend example
* more elegant solution for legend.getLabel

* repaired getLabel
ItemSample.item == plotitem

Co-authored-by: Ogi Moore <ognyan.moore@gmail.com>
2020-06-12 22:40:20 -07:00
Ogi Moore
dbdd5d9a39
Peque scatter symbols (#1244)
* Added arrow symbols for the ScatterPlotItem

* Fixed arrows rotation in scatter plots

* Added new symbols to example

Co-authored-by: Miguel Sánchez de León Peque <msdeleonpeque@gmail.com>
2020-06-10 23:03:43 -07:00
Maurice van der Pot
e18af48b8d
Implement headWidth parameter for arrows (#385)
Although the documentation used to say that specifying tipAngle would
override headWidth, headWidth was never used. The new behaviour is that
tipAngle will be used, with a default value of 25, unless headWidth is
specified.

Co-authored-by: Ogi Moore <ognyan.moore@gmail.com>
2020-06-09 22:04:29 -07:00
Ogi Moore
517adc87c0
Merge branch 'master' into develop 2020-06-09 20:56:51 -07:00
Ogi Moore
47f06e78be
Merge branch 'develop' into pyside2-uic 2020-06-03 21:48:16 -07:00
Ogi
ab96ca1d30 Examples Should Be Tested on PySide2 5.14.2.2 2020-06-02 22:44:17 -07:00
Adam Strzelecki
983cc1695e
Patch/window handling (#468)
* Do not wrap PlotView/ImageView

There is no need to wrap PlotView/ImageView into QMainWindow, since
only purpose of the QMainWindow is some default menu toolbar & menu
handling, that is not used by PyQtGraph anyway.

Moreover, every parent-less Qt widget can become window, so this
change just use PlotView/ImageView as windows, removing extra
complexity, eg. method forwarding, self.win property.

Another benefit of this change, it that these windows get initial
dimensions and titles as they were designed in .ui file.

* Properly cleanup on ImageView.close()

We should not close explicitly child widgets or clear scene, otherwise
Qt will deallocate children views, and cause "wrapped C/C++ object of
type ImageItem has been deleted" error next time we call close()
and/or some other methods.

All children, including self.ui.roiPlot, self.ui.graphicsView will be
closed together with its parent, so there is no need to close them
explicitly.

So the purpose of close it to reclaim the memory, but not to make the existing ImageView object dysfunctional.

* Remove references to plot & image windows after close

PyQtGraph images and plots module list variables are currently holding
references to all plots and image windows returned directly from main
module. This does not seem to be documented however, and causes the Qt
windows to be not released from memory, even if user releases all own
references.

This change removes the references from images/plots list once window
is closed, so when there is no other reference, window and all related
memory is reclaimed.

* Change all UI forms title from Form to PyQtGraph

Co-authored-by: Ogi Moore <ognyan.moore@gmail.com>
2020-06-01 11:23:18 -07:00
Luke Campagnola
9d1fbb6a3e Add warning about PySide 5.14, avoid a confusing error message that would appear with 5.14 2020-05-29 23:42:35 -07:00
Marko Bausch
4052f0dd11 Added context menu option to paramtree 2020-05-22 16:05:52 +02:00
Lev Maximov
a76d9daec2
Date axis item (#1154)
* Add DateAxisItem

* Change style to camelCase

* Fix missing first tick for negative timestamps

* Add ms precision, auto skipping

Auto skipping allows a zoom level to skip ticks automatically if the
maximum number of ticks/pt is exceeded

* fixes suggested by @goetzc

* workaround for negative argument to utcfromtimestamp on windows

* attachToPlotItem method

* default date axis orientation

* Use new DateAxisItem in Plot Customization example

* attachToPlotItem bugfix

* examples of DateAxisItem

* modified description of customPlot example

* added descriptions to the new examples, reformatted their code, included the first one into utils.py

* typo

* Refactored code for setting axis items into new function

Replaces "DateAxisItem.attachToPlotItem"

* Fix string comparison with ==

* Doc: Slightly more text for DateAxisItem, small improvement for PlotItem

* Make PlotWidget.setAxisItems official

* Fix typo in docstring

* renamed an example

* merge bug fix

* Revert "merge bug fix"

This reverts commit 876b5a7cdb.

* Real bug fix

* support for dates upto -1e13..1e13

* Automatically limit DateAxisItem to a range from -1e12 to 1e12 years

Very large years (|y|>1e13) cause infinite loop, and since nobody
needs time 100 times larger than the age of the universe anyways,
this constrains it to 1e12.

Following suggestion by @axil:
https://github.com/pyqtgraph/pyqtgraph/pull/1154#issuecomment-612662168

* Also catch ValueErrors occuring on Linux before OverfloeErrors

While zooming out, before hitting OverflowErrors, utctimestamp
produces ValueErrors (at least on my Linux machine), so they
are also catched.

* Fix: Timestamp 0 corresponds to year 1970

For large years, x axis labels jump by 1970 years if it is not
accounted for timestamp 0 to be equal to year 1970.

* Fix: When zooming into extreme dates, OSError occurs

This commit catches the OSError like the other observed errors

* Disable stepping below years for dates outside *_REGULAR_TIMESTAMP

2 reasons: First: At least on my Linux machine, zooming into
those dates creates infinite loops. Second: Nobody needs
sub-year-precision for those extreme years anyways.

* Adapt zoom level sizes based on current font size and screen resolution

This is somewhat experimental. With this commit, no longer 60 px are
assumed as width for all zoom levels, but the current font and
display resolution are considered to calculate the width of ticks in
each zoom level. See the new function `updateZoomLevels` for
details.
Before calling this function, overridden functions `paint` and
`generateDrawSpecs` provide information over the current display
and font via `self.fontScaleFactor` and `self.fontMetrics`.

* Meaningful error meassage when adding axis to multiple PlotItems

As @axil noted in the DateAxisItem PR, currently users get a
segmentation fault when one tries to add an axis to multiple
PlotItems. This commit adds a meaningful RuntimeError message
for that case.

* setZoomLevelForDensity: Refactoring and calculating optimal spacing on the fly

* DateTimeAxis Fix: 1970 shows when zooming far out

* Refactoring: Make zoomLevels a customizable dict again

* updated the dateaxisitem example

* Fix: Get screen resolution in a way that also works for Qt 4

This is both a simplification in code and an improvement in backwards compatibility with Qt 4.

* DateAxisItem Fix: Also resolve time below 0.5 seconds

* unix line endings in examples

* DateTimeAxis Fix: For years < 1 and > 9999, stepping broke

Stepping was off by 1970 years for years < 1 and > 9999,
resulting in a gap in ticks visible when zooming out. Fixed by
subtracting the usual 1970 years.

* DateTimeAxis Fix: Zooming out too far causes infinite loop

Fixed by setting default limits to +/- 1e10 years. Should still
be enough.

* improved second dateaxisitem example

* 1..9999 years limit

* DateTimeAxis: Use OrderedDict to stay compatible with Python < 3-6

* DateAxisItem: Use font height to determine spacing for vertical axes

* window title

* added dateaxisitem.rst

* updated index.rst

Co-authored-by: Lukas Heiniger <lukas.heiniger@sed.ethz.ch>
Co-authored-by: Lev Maximov <lev.maximov@gmail.com>
Co-authored-by: 2xB <2xB@users.noreply.github.com>
2020-04-27 11:43:22 -07:00
Ogi Moore
556ba55be3
Merge pull request #1124 from dargor/color_examples
Syntax highlighting for examples.
2020-03-08 07:19:54 -07:00
Gabriel Linder
d0b92349dd
Intercept light/dark modes transitions on MacOS. 2020-03-08 10:34:54 +01:00
Gabriel Linder
412698c8bb
Dark mode support. 2020-03-07 23:02:40 +01:00
Ogi
19ae94765f Skip tests involving loadUi with pyside2 5.14 2020-02-24 23:00:42 -08:00
Gabriel Linder
adba81a8d8
Syntax highlighting for examples. 2020-02-11 11:23:58 +01:00
Ogi Moore
2203933393
Declare scipy optional (#1067)
* Replace use of scipy.random with numpy.random

* Update README to reflect scipy being an optional depenency
2019-11-12 09:02:08 -08:00
Elliott Sales de Andrade
d726a9693e Fix UnboundLocalError in VideoSpeedTest. 2019-09-13 01:07:57 -04:00
Ogi Moore
584c4516f0
Expand CI + pre-commit (#991)
* Initial attempt at extra checks in CI land

* Adding flake8 config

* Adding pre-commit configuration and explanation in CONTRIBUTING.md
2019-08-29 13:56:25 -07:00
2xB
05aa3e9393 Add 'fillOutline' option to draw an outline around a filled area (#999) 2019-08-17 09:57:40 -07:00
Ogi
fe637512b5 Skip GL* examples if on macOS with python2 and qt4 bindings, and update readme 2019-06-25 23:05:38 -07:00
2xB
edf2942010 Replaced usage of deprecated ROI classes in example (#946) 2019-06-21 21:19:02 -07:00
Ogi Moore
0cc4900d7a
Skip some test examples (#937)
* Skip RemoteSpeedTest.py during testing
* Skip `optics_demos.py` test on PySide 1. 2.4  due to documented pyside bug
2019-06-21 08:36:42 -07:00
Ogi
f05ff6fbf9 Restore duplicate entries in examples app, but test_examples does not duplicate tests 2019-06-10 21:20:31 -07:00
Ogi
be0e95ace7 Incorporating requested changes 2019-06-03 20:49:31 -07:00
Ogi
9f66b7dc6e Much better error reporting/tracepacks on examples 2019-06-02 22:16:35 -07:00
Ogi
d2331bde7f Removing duplicate entries 2019-06-01 22:36:29 -07:00
Ogi
5ff409ba4b Move example test code such that pytest is required 2019-06-01 22:36:11 -07:00
Ogi Moore
eb90616ae2
Merge pull request #905 from 2xB/test_exclude_examples
Exclude selected examples from tests (such as HDF5)
2019-05-31 22:28:54 -07:00
Luke Campagnola
52fef555ee
Merge pull request #904 from j9ac9k/take-screenshots
Take screenshots + Show Resolution
2019-05-29 13:12:12 -07:00