seantronsen / pvt

GNU General Public License v3.0
0 stars 0 forks source link

BUG: Axes ticks overlap when using log scaling #38

Closed ghoulapool closed 6 months ago

ghoulapool commented 6 months ago

I need log scales on x and y axis as a possibility. Here's the way I plot this in MPL:

 ax.set_yscale('log')
 ax.set_xscale('log')

And it makes a plot like this (notice the x/y log axes):

image

But in this tool it's hard to read bc it looks like this: image

ghoulapool commented 6 months ago

Close this, it's built in ty.

seantrons commented 6 months ago

Discussed issue on an external platform with the issue author. There is a builtin solution for this provided by PyQtGraph and the library wires into that with some kwargs that I need to do a better job documenting.

Anyways, the solution to this is specifying the logx=True and logy kwargs as arguments to the constructor for any of the Plot2d* plotting classes.

There are also kwargs for axes grids that use the same interface gridx and gridy.

Example:

pl = Plot2DLinePane(callback, ncolors=3, cmap="plasma", logx=True, logy=True, gridx=True, gridy=True)
seantrons commented 6 months ago

Changing this issue based on conversation with the original poster (external). There is an issue with the axes tick labels when the log scale is used. Simply put, they can overlap and occlude each other with smaller (v < 1e-3) values.

image

seantrons commented 6 months ago

There is no dedicated easy fix for this in terms of using PyQtGraph's API except for merely widening the graph. Honestly, it makes some sense since it's rather simple to run into this issue with Matplotlib when creating small plots.

There are some "hacky" things that could be done here like manually specifying the axes tick values: https://pyqtgraph.readthedocs.io/en/latest/api_reference/graphicsItems/axisitem.html https://pyqtgraph.readthedocs.io/en/latest/_modules/pyqtgraph/graphicsItems/AxisItem.html#AxisItem.setLogMode

But none form good long terms solutions. Making wider graphs (usually by resizing the window) is the best option here.

Closing.