Skip to content

AxisItem: Add adjustable label overlap tolerances, vertical overlap by default#2836

Merged
j9ac9k merged 2 commits intopyqtgraph:masterfrom
NilsNemitz:Tweak_AxisItem_label_overlap
Nov 11, 2023
Merged

AxisItem: Add adjustable label overlap tolerances, vertical overlap by default#2836
j9ac9k merged 2 commits intopyqtgraph:masterfrom
NilsNemitz:Tweak_AxisItem_label_overlap

Conversation

@NilsNemitz
Copy link
Copy Markdown
Contributor

This extends / adjusts the functionality added in #2385 to stop axis labels sticking out of the allocated space. That certainly avoids overlap, it leaves less room for labels, and makes it so that ticks at the edges of the axis are never labeled.

The main problem identified in #2385 was an overlap of the x-axis labels of adjacent plots in a layout. While the width of the x-axis plots grows for larger numbers, the height of the y axis labels remains constant, so overlap is much less problematic there.

This PR

  • changes the default AxisItem behavior to allow tick labels for the vertical axis to extend outside the boundary box.
  • adds the option of passing an integer tolerance value for hideOverlappingLabels to allow a user specified amount of overlap: The default of 15 pixels tolerance for enabled overlap is too small at larger font sizes. This functionality was discussed for Add style option 'hideOverlappingLabels' #2385, but wasn't ultimately added. The previously allowed values of True and False function the same as before.
  • fixes a bug where the label tolerance accidentally remained hardcoded for the top axis.
  • adds an example to show the effect of the setting and give demonstration code
  • fixes an unrelated documentation error in setTickSpacing()

example AxisItem - label overlap

@j9ac9k
Copy link
Copy Markdown
Member

j9ac9k commented Nov 11, 2023

Thanks @NilsNemitz sorry for the wait, this LGTM, merging!

@j9ac9k j9ac9k merged commit d5ace19 into pyqtgraph:master Nov 11, 2023
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.

2 participants