AxisItem: Allow hiding minor ticks#3318
Conversation
Fixes pyqtgraph#3250 . This can be used as follows, adapting the example from the above issue: ``` import pyqtgraph as pg from PyQt5.QtGui import QGuiApplication app = pg.mkQApp() # Create window win = pg.GraphicsLayoutWidget(show=True) win.setWindowTitle('pyqtgraph example: Scrolling Plots') # Add plot plot = win.addPlot(1, 1, pen=pg.mkPen(color='#000000')) # Show grid plot.showGrid(x=True, y=True) plot.getAxis('bottom').style["maxTickLevel"] = 0 plot.getAxis('left').style["maxTickLevel"] = 0 app.exec() ```
|
Hello, I have just tested this with the newest version (0.13.7) from PyPI, everything works great, thank you very much for this. |
|
Hi @2xB, thank you for adding internal logic for the sub ticks. The code should absolutely have that! There's probably a follow-up discussion to be had what a reasonable API might look like, since currently #2827 tried to touch the overall logic as little as possible. It tried to adjust the math to produce a helpful number of ticks (e.g. more than one, I think) in a wider range of cases. The same adjustments also allowed the existing minor tick logic to actually produce visible ticks more regularly, I believe that produced the change that #3250 points out. There's no deeper meaning to the appearance of extra ticks. |
|
Thank you very much for the responses! Interacting with the style dictionary directly instead of through a proper function is my fault, there already exists a proper interface: plot.getAxis('bottom').setStyle(maxTickLevel=0)
plot.getAxis('left').setStyle(maxTickLevel=0)I've also adapted the code in the above message. |
|
@2xB this looks good to me and is a nice, efficiently minimal change. Could you maybe add a short description of the |
As suggested by @NilsNemitz
|
@NilsNemitz Sure, I added a short documentation to |
|
Thank you! Given the name of the might be a reasonable inclusion? |
Similar to the suggestion by @NilsNemitz
|
Sure! I minorly rephrased it so the grid is mentioned in a concise description at the beginning of the text. |
|
Hi @2xB , we've been having some trouble with the tests, which might be better now. If you make another change, the tests should rerun automatically, and we'll see. On that note, maybe you could go to line 234 and change ? |
Thanks to @NilsNemitz for the suggestion!
Fixes #3250, which originated from #2827 (therefore maybe @NilsNemitz has an opinion on this?).
This can be used as follows, adapting the example from the above issue:
@mfeingesicht Could you test if this solves your use case?