Skip to content

Fix bug in PlotItem.setAxisItem when called befor scene is set#3182

Merged
j9ac9k merged 1 commit intopyqtgraph:masterfrom
tblum:bugfix_setaxisitem
Jan 25, 2025
Merged

Fix bug in PlotItem.setAxisItem when called befor scene is set#3182
j9ac9k merged 1 commit intopyqtgraph:masterfrom
tblum:bugfix_setaxisitem

Conversation

@tblum
Copy link
Copy Markdown
Contributor

@tblum tblum commented Nov 4, 2024

Calling PlotItem.setAxisIten before the Plot is added to a scene will cause an AttributeError exception to be raises.
E.g. in this example. This pullrequest avoids that.

import numpy as np
import pyqtgraph as pg

w = pg.GraphicsLayoutWidget()
x = np.linspace(0, 6, 1000)
y = np.sin(x)
p = pg.PlotItem(x=x, y=y)
p.setAxisItems({'bottom': pg.AxisItem(orientation='bottom', pen='r')})
w.addItem(p)
w.show()

if __name__ == '__main__':
    print(pg.__version__)
    pg.exec()

@tblum tblum force-pushed the bugfix_setaxisitem branch from abfe259 to 92d379d Compare November 6, 2024 12:37
@j9ac9k
Copy link
Copy Markdown
Member

j9ac9k commented Jan 25, 2025

Thanks for the PR @tblum This diff LGTM, merging!

@j9ac9k j9ac9k merged commit bd8bd56 into pyqtgraph:master Jan 25, 2025
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

Successfully merging this pull request may close these issues.

3 participants