I want to examine a vector field and therefore i used "quiver" to
visualize said field:
import numpy as np
import matplotlib.pyplot as plt
x, y = np.meshgrid(np.arange(0, 2*np.pi, 0.1),
np.arange(0, 1*np.pi, 0.1))
dx = -2*np.sin(x)*np.cos(y)
dy = np.cos(x)*np.sin(y)
plt.quiver(dx, dy, color='b')
# beautiful axis
a = plt.gca()
x_a, y_a = a.get_xaxis(), a.get_yaxis()
# TODO: We should not multiply with 10 here.
x_a.set_ticks(np.arange(0, 2*np.pi*10+1, np.pi*10/4))
y_a.set_ticks(np.arange(0, 1*np.pi*10+1, np.pi*10/4))
labels = [
(The plot looks like a double swirl, if anyone is interested in that
At first I do not know why I have to multiply with 10 at the ticks, but
thats not the point.
It is much more important that I would like to set the image to a
certain width before saving. It should be both "tight" and "equal", so
after setting the width the height could be calculated automatically.
As a workaround I use the images and strech them vertically, but then
the x/y axis tick labels look strange.
So: How to set a certain width?
Thanks and a merry Christmas,