-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Description
Short description
The PlotCurveItem options fillLevel, brush and shadowPen are not able to be reset to their non-active state of None from PlotDataItem keyword arguments. Some of them can only be deactivated by calling methods.
brush and shadowPen could be deactivated by calling PlotDataItem methods setBrush(None) and setShadowPen(None), although this only changes their styles to NoBrush and NoPen, so may not be strictly equivalent to being able to reset to None.
Code to reproduce
import pyqtgraph as pg
from pyqtgraph.Qt import QtGui
import numpy as np
def print_opts(title, opts):
print(title)
print("fillLevel :", opts['fillLevel'])
brush = opts['brush']
if isinstance(brush, QtGui.QBrush):
print("brush :", brush.style(), brush.color().name())
else:
print("brush :", brush)
pen = opts['shadowPen']
if isinstance(pen, QtGui.QPen):
print("shadowPen :", pen.style(), pen.color().name())
else:
print("shadowPen :", pen)
print()
pg.mkQApp()
if 1:
item = pg.PlotDataItem()
curve = item.curve
else:
# try out using a PlotCurveItem directly
item = pg.PlotCurveItem()
curve = item
# setup initial values
item.setData(np.arange(10), fillLevel=0.0, brush='b', shadowPen='g')
print_opts('INITIAL', curve.opts)
# none of the 3 options can be reset via keywords
item.setData(np.arange(10), fillLevel=None, brush=None, shadowPen=None)
print_opts('MODIFY VIA KEYWORDS', curve.opts)
# fillLevel cannot be reset via method call either
item.setFillLevel(None)
item.setBrush(None)
item.setShadowPen(None)
item.setData(np.arange(10))
print_opts('MODIFY VIA METHODS', curve.opts)Expected behavior
INITIAL
fillLevel : 0.0
MODIFY VIA KEYWORDS
fillLevel : None
MODIFY VIA METHODS
fillLevel : None
Real behavior
OUTPUT:
INITIAL
fillLevel : 0.0
brush : BrushStyle.SolidPattern #0000ff
shadowPen : PenStyle.SolidLine #00ff00
MODIFY VIA KEYWORDS
fillLevel : 0.0
brush : BrushStyle.SolidPattern #0000ff
shadowPen : PenStyle.SolidLine #00ff00
MODIFY VIA METHODS
fillLevel : 0.0
brush : BrushStyle.NoBrush #000000
shadowPen : PenStyle.NoPen #c8c8c8
Tested environment(s)
- PyQtGraph version: 0.12.3
- Qt Python binding: PyQt6 6.2.0
- Python version: 3.8.10
- NumPy version: 1.21.3
- Operating system: Windows 10
- Installation method: pip install -e .
Additional context
fillLevel can be reset to None by calling PlotCurveItem.setFillLevel(None) but not by calling PlotDataItem.setFillLevel(None).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels