Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different logarithmic scale behavior when compared to Qwt #94

Closed
nicoddemus opened this issue Dec 27, 2024 · 6 comments
Closed

Different logarithmic scale behavior when compared to Qwt #94

nicoddemus opened this issue Dec 27, 2024 · 6 comments

Comments

@nicoddemus
Copy link
Contributor

Hi folks,

We are having different results when using the logarithmic scale compared with Qwt.

Qwt

from PyQt5.QtWidgets import QApplication
from Qwt5 import QwtPlot, QwtPlotCurve, QwtLog10ScaleEngine


app = QApplication([])
plot = QwtPlot()
plot.setWindowTitle("Qwt")
plot.resize(800, 600)

y = [1, 500, 1000, 1500]
x = [1, 2, 3, 4]

curve = QwtPlotCurve()
curve.setData(x, y)

engine = QwtLog10ScaleEngine()
plot.setAxisScaleEngine(QwtPlot.yLeft, engine)

curve.attach(plot)
plot.show()
app.exec()

image

PythonQwt

from PyQt5.QtWidgets import QApplication
from qwt import QwtPlot, QwtPlotCurve, QwtLogScaleEngine


app = QApplication([])
plot = QwtPlot()
plot.setWindowTitle("PythonQwt")
plot.resize(800, 600)

y = [1, 500, 1000, 1500]
x = [1, 2, 3, 4]

curve = QwtPlotCurve()
curve.setData(x, y)

engine = QwtLogScaleEngine()
plot.setAxisScaleEngine(QwtPlot.yLeft, engine)

curve.attach(plot)
plot.show()
app.exec()

image


The original Qwt scale looks right, but PythonQwt is not really logarithmic... any ideas what the problem might be? I suspect it might be related to the fact that now PythonQwt uses a better overall auto range calculation to give some room on each side of each axis (which looks much better in normal situations), but this extra room might not be playing well with the old logarithmic scaling code, but this is just a hunch.

I did look at the QwtLogScaleEngine.autoScale method in comparison with the original, and everything seems well.

Any hints/suggestions would be greatly appreciated! 👍

@PierreRaybaut
Copy link
Collaborator

After a quick overview, still no clue.
I'll have to look further into it.

@PierreRaybaut
Copy link
Collaborator

PierreRaybaut commented Dec 31, 2024

After some debugging, I confirm that everything works as expected in autoScale method (and in all functions and methods called in it).

I found out that this is coming from commit 3cf995f (when margin is set to None, everything works as expected).

@PierreRaybaut
Copy link
Collaborator

@nicoddemus : please confirm that it's fixed on your side. Should be 🤞

@nicoddemus
Copy link
Contributor Author

Yep, I can confirm it works great, thanks a lot for this!

@PierreRaybaut
Copy link
Collaborator

@nicoddemus : perfect! Let me know if you need a new release soon: that would be understandable considering this bug which could be quite annoying.

@nicoddemus
Copy link
Contributor Author

A new release soon would be great, thanks! But no rush though.

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

No branches or pull requests

2 participants