Hello,
I am using PyPlot and I cannot figure out how to change the aspect ratio of a plot. I googled for some answers and I found a thread from Python users about aspect ratios in Matplotlib:
I am trying to make sense of that thread, and imagine how to do something similar in Julia, but so far my attempts have failed. The closest I got is to make a "subplot", but I don't know how to plot inside a subplot. Here is what I tried:
julia> using PyPlot
INFO: Loading help data...
julia> aspect
ERROR: aspect not defined
julia> ax = axes()
PyObject <matplotlib.axes.AxesSubplot object at 0x7f5c378fc4d0>
julia> methods(ax)
ERROR: `methods` has no method matching methods(::PyObject)
julia> fig = figure(2)
Figure(PyObject <matplotlib.figure.Figure object at 0x7f5c376cda10>)
julia> methods(fig)
ERROR: `methods` has no method matching methods(::Figure)
julia> subplot(111, aspect=3)
PyObject <matplotlib.axes.AxesSubplot object at 0x7f5c376d3090>
AHA! So the last line correctly creates a plot with the desired aspect ratio. But I don't know where to go from there. The moment I try to plot anything, the aspect ratio resets. I do have the basic idea of how subplots work:
--------------------------
using PyPlot
x = linspace(0,2pi);
subplot(211)
plot(x,sin(x))
subplot(212)
plot(x,cos(x))
--------------------------
So I was expecting to be able to do this:
--------------------------
using PyPlot
x = linspace(0,2pi);
subplot(111, aspect=3)
plot(x,sin(x))
--------------------------
I was expecting that this would give me a plot that looks like a very tall sine wave. But it doesn't. The moment I run the plot() command, the aspect ratio resets.
Can anyone help me?
Cheers,
Daniel.