-
Notifications
You must be signed in to change notification settings - Fork 25
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
Add support for geometry based axis auto-scaling #39
Comments
Do you mean that adding the following code to your class MyPlot(QwtPlot):
def resizeEvent(self, event):
QwtPlot.resizeEvent(self, event)
self.replot() |
Ah. Hm, I'm not sure, I'll give it a try, but I'm doubtful. The call to |
I made the following test: from os import environ
from sys import argv, exit
from numpy import linspace, sin, pi
from PyQt5.QtWidgets import QApplication, QMainWindow
environ['QT_API'] = 'pyqt5'
from qwt import QwtPlot, QwtPlotCurve
class TestPlot1(QwtPlot):
"""Without resizeEvent overridden."""
def __init__(self, parent=None):
super(TestPlot1, self).__init__(parent)
y = linspace(0, 2*pi, 500)
curve = QwtPlotCurve('Test Curve')
curve.setData(sin(y), y)
curve.attach(self)
self.replot()
class TestPlot2(QwtPlot):
"""With resizeEvent overridden."""
def __init__(self, parent=None):
super(TestPlot2, self).__init__(parent)
y = linspace(0, 2*pi, 500)
curve = QwtPlotCurve('Test Curve')
curve.setData(sin(y), y)
curve.attach(self)
self.replot()
def resizeEvent(self, event):
QwtPlot.resizeEvent(self, event)
self.replot()
if __name__ == '__main__':
app = QApplication(argv)
plot1 = TestPlot1()
window1 = QMainWindow()
window1.setWindowTitle("Without resizeEvent overridden")
window1.setCentralWidget(plot1)
window1.show()
plot2 = TestPlot2()
window2 = QMainWindow()
window2.setWindowTitle("With resizeEvent overridden")
window2.setCentralWidget(plot2)
window2.show()
exit(app.exec_()) And both plots resists resizing them smaller than what the current laid out axes permit. What I'm looking for is a way to be able to have the automatic axes divisions automatically updated to allow resizing it even smaller. |
I'm currently using auto-scaling for my X-axis, but I noticed that I'm still prevented from making the plot smaller beyond a certain point. It would be great if the axis auto-scaling feature could work such that the axis division is recalculated based on the new size when the geometry of the widget changed, not just when
replot
→updateAxes
is called. This would allow a dynamic behavior where the division of the axis scale is coarser when the plot is narrow, and finer when it is wide.The text was updated successfully, but these errors were encountered: