Commit Graph

599 Commits

Author SHA1 Message Date
Ogi
66d8943317 PlotItem doesn't add item if already there 2020-06-08 21:50:29 -07:00
Ogi Moore
5b5749aa0b Revert "changed structure to redefine axis via plotitem.setAxes (#391)"
This reverts commit bb21791c71.
2020-06-07 20:29:28 -07:00
Kenneth Lyons
120d251a25 Minor improvements to LegendItem.
- Adds doc strings for user-facing methods so they appear in the
  documentation.
- Allows PlotItem.addLegend to accept the same arguments as LegendItem
  constructor for convenience.
- Fixes a bug for adding a BarGraphItem (which doesn't have an antialias
  option) to LegendItem
2020-06-06 15:56:01 -07:00
Karl Georg Bedrich
ca9b0c7910
new method 'getAxpectRatio' with code taken from 'setAspectLocked' (#392)
Co-authored-by: Ogi Moore <ognyan.moore@gmail.com>
2020-06-01 11:24:18 -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
Karl Georg Bedrich
bb21791c71
changed structure to redefine axis via plotitem.setAxes (#391)
* changed structure to redefine axis via
plotitem.setAxes

* cleanuup

* remove old axesitems before adding new ones

* DEBUGGED plotitem.setAxes
NEW AxisItem.setOrientation (needed by plotitem.setAxes)
show/hide right axes after .setAxes()

Co-authored-by: Ogi Moore <ognyan.moore@gmail.com>
2020-06-01 11:12:52 -07:00
Ogi Moore
a27506209b
Merge pull request #393 from radjkarl/gradient
NEW show/hide gradient ticks NEW link gradientEditor to others
2020-05-31 21:03:27 -07:00
Zach Lowry
c903546679
Fix duplicate menus in GradientEditorItem (#444)
* Fix duplicate menus in GradientEditorItem

Add call to ev.accept in Tivk.mouseClickEvent to prevent parent menu from opening on a right click of a Tick.

Co-authored-by: Ogi <ognyan.moore@gmail.com>
2020-05-31 17:39:51 -07:00
ChristophRose
ed009d3779 Check lastDownsample in viewTransformChanged
Add a check in the viewTransformChanged function to only force a rerender when the downsampling factor changed.
Previously simply moving the image around or zooming in/out without changing the downsampling factor would force a complete rerendering of the image, which was very slow with large images. This way, the expensive rerender is only forced if necessary.
2020-05-30 22:15:52 -07:00
Paul Müller
e08ac110f5
pretty-print log-scale axes labels (#1097)
* pretty-print log-scale axes labels

* only pretty-print in python 3
2020-05-30 13:53:38 -07:00
Israel Brewster
949df4da16
Fix aspectRatio and zoom range issues when zooming (#1093)
* Check and enforce view limits in the setRange function

* Check limits when setting aspectRatio

- This change is required due to moving the limit checking out of the updateViewRange function.
- If the original logic remained, aspect ratio could be lost due to "squshing" the requested view into the viewBox

* Add tests for ViewBox zooming limits and aspect ratio

* - Move test code to proper location and fix instantiation of QApplication

Co-authored-by: Israel Brewster <ijbrewster@alaska.edu>
2020-05-30 13:09:09 -07:00
Ogi Moore
2ac1eefeb5
Merge pull request #1173 from 2xB/fix-1136-2
GraphicsLayout: Always call layout.activate() after adding items
2020-05-30 13:04:37 -07:00
Erik Månsson
55e1f2c520 Add cache for mapRectFromView 2020-05-30 16:25:43 +02:00
Daniel Hrisca
6194245322
improve SymbolAtlas.getSymbolCoords and ScatterPlotItem.plot performance (#1198) 2020-05-29 23:08:40 -07:00
Ogi Moore
99c43613f3
Merge pull request #1174 from Ma-Shell/develop
Fixed a possible race condition with linked views
2020-05-29 23:00:10 -07:00
Erik Månsson
369d7a11d2 Fix PixelVectors cache 2020-05-28 23:10:00 +02:00
Kenneth Lyons
5353acdb1c Static paths not used for docs. Fix malformed table in docstring 2020-05-16 10:12:33 -07:00
Kyle Sunden
fb56d3eaa9
Merge pull request #801 from ales-erjavec/remove-address-cache
Remove use of GraphicsScene._addressCache in translateGraphicsItem
2020-05-11 10:38:39 -05:00
Maxim Millen
14075e6223
Added support for plot curve to handle both fill and connect args. (#1188) 2020-05-10 08:42:04 -07:00
Kenneth Lyons
5bebf697b0
Disable remove ROI menu action in handle context menu (#1197) 2020-05-10 08:39:17 -07:00
2xB
720fa5f3c2
DateAxisItem: AxisItem unlinking tests and doc fixed (#1179)
* Added test_AxisItem by @mliberty1

As found in https://github.com/pyqtgraph/pyqtgraph/pull/917

* test_AxisItem: Fit to current implementation

* DateAxisItem: Fix documentation to zoomLevels

zoomLevels is not intended to be set by the user (see discussion in converstation from
https://github.com/pyqtgraph/pyqtgraph/pull/1154/files#diff-aefdb23660d0963df0dff3a116baded8
). Also, `zoomLevelWidths` does currently not exist.
This commit adapts the documentation to reflect that.

* DateAxisItem: Do not publish ZoomLevel

* DateAxisItem testing: Removed unnecessary monkeypatch fixture

Co-authored-by: 2xB <2xB@users.noreply.github.com>
2020-05-05 09:16:07 -07:00
2xB
96be1bd23f
Fix: AxisItem tickFont is defined in two places while only one is used (#1180)
To set the tick font of `AxisItem`s, there are two options:
`setStyle({"tickFont":...})` and `setTickFont(...)`.
The first option sets `AxisItem.style['tickFont']`, the second
sets `self.tickFont`. Only `self.tickFont` is actually used.
This PR replaces all occurrences of the second variable with the first
variable, so both options work again. Also, documentation from
`setStyle` is copied to `setTickFont`.

Co-authored-by: 2xB <2xB@users.noreply.github.com>
2020-05-04 14:58:29 -07:00
Daniel Hrisca
f7364f52b3
improve SymbolAtlas.getSymbolCoords performance (#1184)
* remote legacy work-around for old numpy errors

* forgot to remove the numpy_fix import

* require numyp >= 1.8.0

* improve performance of updateData PlotCurveItem (saves about 2us per call)

* improve ScatterPlotItem performance
2020-05-04 13:42:03 -07:00
Ales Erjavec
02b7532706 Remove use of GraphicsScene._addressCache in translateGraphicsItem
Use QGraphicsItem.toQGrapicsObject on the item instead.

This probably is not even needed since PyQt 4.9
2020-05-01 13:05:51 +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
Marcel Schumacher
a697b5584a Fixed a possible race condition with linked views 2020-04-14 17:24:54 +02:00
2xB
ec66c34fc9 GraphicsLayout: Always call layout.activate() after adding items
Items added to a `GraphicsLayout` only learn their size information
after the internal `QGraphicsGridLayout` recalculates the layout.
This is happening as a slot in the Qt event queue.
Not having updated geometry bounds directly after adding an item
leads to multiple issues when not executing the Qt event loop
in time (see below). This commit fixes that by always calling
`layout.activate()` after adding items, updating item sizes
directly.

This is a follow-up to PR #1167, where introducing a direct call to
`processEvents` was suspected to be able to cause side effects.

Notifying @j9ac9k and @campagnola, as they were involved in #1167.

Fixes #8
Fixes #1136
2020-04-14 02:00:49 +02:00
2xB
71636e3518 Fix: Update axes after data is set 2020-04-08 17:11:20 +02:00
lcmcninch
a5dd549be1
Pass showAxRect keyword arguments to setRange to allow caller to set padding, etc. (#1145)
Co-authored-by: Luke McNinch <lucas.c.mcninch.civ@mail.mil>
2020-04-03 15:33:21 -07:00
Kenneth Lyons
db67a256a9
Miscellaneous doc fixups (#1142)
* Miscellaneous doc cleanup

* Moved dockarea up a level (like flowchart, parametertree). Removed extraneous parametertree doc
2020-04-03 10:06:25 -07:00
Ogi Moore
a8d1a84870
Merge pull request #1063 from ales-erjavec/view-box-enable-menu-fix
Fix: AttributeError in ViewBox.setEnableMenu
2020-03-06 16:16:14 -08:00
Ogi Moore
93f8ee9f0a
Merge pull request #1111 from JoeXinfa/add-label
Add name label to GradientEditorItem
2020-03-06 15:30:57 -08:00
Ogi Moore
5cd19ba7a0
Merge pull request #1139 from SamSchott/patch-1
Bug fix in LegendItem for `setPen`, `setBrush` etc
2020-03-06 11:26:48 -08:00
SamSchott
3509d79c0f
bug fix for setPen, setBrush, ...
Fixes a bug where `setPen`, `setBrush` and `setLabelTextColor` would fail because they call `LegendItem.paint` without a pen. They should instead call `LegendItem.update`.
2020-03-06 15:02:39 +00:00
Ogi
3158c5b4db Use int() instead of .__int__() 2020-02-29 14:38:19 -08:00
Ognyan Moore
6ed8a405fe Address FutureWarning about implicit float to int conversions 2020-02-28 14:27:10 -08:00
Ognyan Moore
f0d1c4eda1 Skipping problematic test on py2/qt4/linux 2020-02-24 22:30:27 -08:00
Kenneth Lyons
61104cd43c Fix small oversight in LegendItem 2019-12-24 10:04:31 -08:00
Paul Müller
2a01c3848a
fix wrong offset when drawing symbol 2019-11-25 14:14:15 +01:00
Paul Müller
b02ada024b
fix error on SVG export of scatter plots: KeyError: 'resolutionScale' 2019-11-23 13:10:49 +01:00
SamSchott
c0ae44bc2d Nicer legend (#958)
* More customizable and nicer legend.

- Give kwargs for legend frame and background colors instead of hard-coded values.
- Reduce spacing for more compact legend
- Give separate kwarg `labelTextColor`.
- New method to clear all legend items.
- New methods to get and change `offset` relative to the legend's parent.
- Horizontal instead of tilted lines for legend pictures.
2019-11-19 21:42:31 -08:00
SamSchott
c95ab570b1 set color of tick-labels separately (#841) 2019-11-19 20:43:27 -08:00
boylea
b1b2f4662b Fixed image scatter plot export bug (#88) 2019-11-19 20:03:15 -08:00
Paul Müller
267a0af8e7 Reset currentRow and currentCol on clear (#1076) 2019-11-19 08:21:36 -08:00
Daniel Hrisca
15a1f5af94 improve performance of updateData PlotCurveItem (saves about 2us per call) (#1079)
* improve performance of updateData PlotCurveItem (saves about 2us per call)
2019-11-19 08:14:53 -08:00
Kenneth Lyons
faef56c3e7 Qulogic py3 fixes (#1073)
* py3k: Remove reduce calls.

* py3k: Remove compatibility sortList function.

Sorting by key has existed since Python 2.4.

* Remove unnecessary sys.path manipulation.

This file doesn't have any __main__ code to run anyway.

* Use context manager
2019-11-12 08:45:42 -08:00
Kenneth Lyons
f5e25622a7 Validate min/max text inputs in ViewBoxMenu (#1074) 2019-11-12 08:36:16 -08:00
Ales Erjavec
a65b8c91f7 Add simple test for setEnableMenu 2019-11-06 10:59:51 +01:00
Ales Erjavec
50cf2f561f Move common code to _applyEnableMenu 2019-11-06 10:58:00 +01:00
Ales Erjavec
a84953530f Fix: setEnableMenu in ViewBox 2019-10-28 14:30:22 +01:00