Skip to content

GridItem: Fix pen for usage of dash-pattern#2304

Merged
j9ac9k merged 1 commit intopyqtgraph:masterfrom
bbc131:grid_item_pen
Jun 5, 2022
Merged

GridItem: Fix pen for usage of dash-pattern#2304
j9ac9k merged 1 commit intopyqtgraph:masterfrom
bbc131:grid_item_pen

Conversation

@bbc131
Copy link
Copy Markdown
Contributor

@bbc131 bbc131 commented May 18, 2022

Hi, I wanted to use a custom dash-pattern for the grid. Currently this doesn't work, the drawn dash pattern changes with the zoom of the plot.
See the attached screenshot showing different vertical and horizontal grid lines, due to the different ranges set at the end of the example.

...
app = mkQApp("Grid bug demo")
plot = PlotWidget()
plot.show()

grid = GridItem()
grid.setPen(dash=[4,4,8,4])
plot.addItem(grid)

plot.setXRange(min=0.0, max=10.0)
plot.setYRange(min=0.0, max=1.0)

grafik

Use a cosmetic pen for the grid and remove unnecessary setting of the width.
See also documentation of QPen.isCosmetic().
@bbc131
Copy link
Copy Markdown
Contributor Author

bbc131 commented May 18, 2022

Note, this should also fixe #1709.
Now, something like grid.setPen(width=4) should work.

Copy link
Copy Markdown
Member

@ixjlyons ixjlyons left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to work well to me. I suspect that was some reason it was setCosmetic(False), but I'm not finding one. Zoom, window resize, export, all seem fine with this change on the examples that use a GridItem. I'm not sure if there's anything else that should be checked.

@j9ac9k j9ac9k merged commit 4b802de into pyqtgraph:master Jun 5, 2022
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