guiqwt: Problem mit set_axis_direction

Python und das Qt-Toolkit, erstellen von GUIs mittels des Qt-Designers.
Antworten
PeterM

Hallo,

ich habe ein Problem mit "set_axis_direction('bottom', reverse=True)" in guiqwt. Wenn ich das anwende, wird offenbar das Aspect-Ratio verändert. Bei Verwendung von "left" gibt es kein Problem. Mache ich was falsch? Ist das Problem bekannt? Gibt es eine Lösung? (Aspekt setzten ist keine!)
Hier ist ein kleines Beispiel, was das Problem zeigt. Wenn man stattdessen plot.set_axis_direction('bottom', reverse=False) ersetzt, ist alles richtig.

Vielen Dank für die Hilfe,
Peter

----------------------------------------------------------------------------------------------------------------

Code: Alles auswählen

#!/usr/bin/env python

import numpy as np

from guiqwt.plot import ImageDialog
from guiqwt.builder import make

def imshow( data ):
    win = ImageDialog(edit=False, toolbar=True, wintitle="TestImage")
    item = make.image(data)
    plot = win.get_plot()
    plot.set_axis_direction('left', reverse=True)
    plot.set_axis_direction('bottom', reverse=True)
    plot.add_item(item)
    win.show()
    win.exec_()

def gaussian(height, center_x, center_y, width_x, width_y):
    """Returns a gaussian function with the given parameters"""
    return lambda x,y: height*np.exp(-(((center_x-x)/width_x)**2+((center_y-y)/width_y)**2)/2)

def compute_image(M=360, N=180):
    x, y = np.mgrid[0:M, 0:N]
    params = (10.0, 0.5*M, 0.5*N, 0.1*M, 0.1*M)
    data = gaussian(*params)(x, y)
    return data

def main():
    """Test"""
    # -- Create QApplication
    import guidata
    _app = guidata.qapplication()
    # --    
    imshow(compute_image())

if __name__ == "__main__":
    main()
Zuletzt geändert von PeterM am Samstag 16. Juni 2012, 22:59, insgesamt 1-mal geändert.
Grund: Code-Tags hinzugefügt
PeterM

Hier nochmal formatiert. 8)

Code: Alles auswählen

#!/usr/bin/env python

import numpy as np

from guiqwt.plot import ImageDialog
from guiqwt.builder import make

def imshow( data ):
    win = ImageDialog(edit=False, toolbar=True, wintitle="TestImage")
    item = make.image(data)
    plot = win.get_plot()
    plot.set_axis_direction('left', reverse=True)
    plot.set_axis_direction('bottom', reverse=True)
    plot.add_item(item)
    win.show()
    win.exec_()

def gaussian(height, center_x, center_y, width_x, width_y):
    """Returns a gaussian function with the given parameters"""
    return lambda x,y: height*np.exp(-(((center_x-x)/width_x)**2+((center_y-y)/width_y)**2)/2)

def compute_image(M=360, N=180):
    x, y = np.mgrid[0:M, 0:N]
    params = (10.0, 0.5*M, 0.5*N, 0.1*M, 0.1*M)
    data = gaussian(*params)(x, y)
    return data

def main():
    """Test"""
    # -- Create QApplication
    import guidata
    _app = guidata.qapplication()
    # --    
    imshow(compute_image())

if __name__ == "__main__":
    main()

Zuletzt geändert von PeterM am Samstag 16. Juni 2012, 23:00, insgesamt 1-mal geändert.
Grund: Syntaxhighlighting aktiviert
webspider
User
Beiträge: 485
Registriert: Sonntag 19. Juni 2011, 13:41

Auch schon den Editier-Button gefunden?
PeterM

webspider hat geschrieben:Auch schon den Editier-Button gefunden?
Super Beitag! Danke sehr hilfreiche Antwort.
Antworten