-
Notifications
You must be signed in to change notification settings - Fork 20
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
How do I create a plot where the scales of x-axis and y-axis are the same? #111
Comments
I'm not sure I fully understand what you mean by "the same". |
@clsgg If you mean a situation where you have an image that is say 3 times wider than it is tall but you want it to plot as a square then you can adjust the aspect ratio like this (self.plot is the plotter for an ImageDialog):
|
Sorry it wasn't described clearly. I've just started using guiqwt, using its matlab-like syntax for drawing. I want to draw a trajectory, and if the X-axis scale is not equal to the Y-axis scale, the trajectory will deform.
@RussBerg ,I don't know how to add the code you mentioned when drawing with matlab-like syntax in guiqwt. |
@PierreRaybaut is going to know the answer to that better than I as I have never used the Matlab like calls, that said it looks like pyplot creates a CurvePlot that does have a methods called set_axis_limits that might allow you to achieve what you want. |
@RussBerg: thanks for your help. What you are looking for is the "lock aspect ratio" feature, which is unfortunately available exclusively for image plots (this limitation will be removed in However, if you want to draw only the trajectory, you can still use the # -*- coding: utf-8 -*-
"""
Test for Issue #111
Interactive plotting interface with MATLAB-like syntax
"""
import numpy as np
from guidata.qthelpers import qt_app_context
from guiqwt.plot import ImageDialog
from guiqwt.builder import make
def show_trajectory(x, y, title, **options):
"""Show a trajectory"""
win = ImageDialog(title, toolbar=True, options=options)
item = make.mcurve(x, y, "g-")
plot = win.get_plot()
plot.add_item(item)
return win
def test():
"""Test"""
t = np.linspace(0, 10, 1000)
x, y = np.cos(t) * t, np.sin(t) * t
with qt_app_context():
show_trajectory(x, y, "Trajectory", xlabel="x", ylabel="y").exec()
if __name__ == "__main__":
test() |
No description provided.
The text was updated successfully, but these errors were encountered: