Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DateAxisItem renders correctly only for one plot if re-added #2968

Open
stan-servaenergy opened this issue Mar 20, 2024 · 1 comment
Open

Comments

@stan-servaenergy
Copy link

Short description

In my app I'd like to able to switch X-axis labels between DateAxisItem and my custom AxisItem. While implementing this, I've noticed that adding DateAxisItem to multiple plots seem to be broken, or at least not working as expected.

Code to reproduce

import pyqtgraph as pg
from PySide6.QtCore import QTimer

cnt = 0


def timer_callback1():
    global cnt
    for pl in plots:
        match cnt % 2:
            case 0:
                pl.setAxisItems({"bottom": pg.DateAxisItem()})
            case 1:
                pl.setAxisItems({"bottom": pg.AxisItem("bottom")})
    cnt += 1


app = pg.mkQApp()

plots = []
win = pg.GraphicsLayoutWidget()

for i in range(2):
    plots.append(win.addPlot(title=f"Plot {i+1}"))
    win.nextRow()

t = QTimer()
t.setInterval(1000)
t.timeout.connect(timer_callback1)
t.start()


win.show()
app.exec()

Expected behavior

The timer toggles between DateAxisItem and AxisItem, both plots always have same labels.

Real behavior

Only first plot is showing correct tick labels when using DateAxisItem. Both plots showing correct tick labels with AxisItem.

Tested environment(s)

  • PyQtGraph version: 0.13.4
  • Qt Python binding: PySide6 6.6.2 Qt 6.6.2
  • Python version: Python 3.11.6
  • NumPy version: 1.26.4
  • Operating system: Ubuntu 23.10
  • Installation method: pip/venv
@stan-servaenergy
Copy link
Author

My analysis seems to point to generateDrawSpecs, which is for some reason producing incorrect width (too small) for the axis (for the second plot), which then causes rest of the pipeline to produce no tick labels.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant