Python Forum
quiver plot scaling help
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
quiver plot scaling help
#1
Hello all,

I have written some code to produce a contour plot (scalar field) and added a quiver plot (vector gradient) to display the gradient:

Contour:
plt.figure()
ax1 = plt.axes()

w = np.arange(-2, 4.1, 0.1)
v = np.arange(-2, 3.1, 0.1)
[x, y] = np.meshgrid(w, v)

f = np.exp(-x**2-y**2) + 0.5*np.exp(-(x-1.5)**2 -2*y**2) 
c = np.arange(0.1, 1.0, 0.1)
ax1.contour(x, y, f, levels=c)

l = np.arange(0.1, 1, 0.2)
ax1.contour(x, y, f, levels=l, linewidths=0.5)
ax1.set_aspect('equal')


Quiver:
w = np.arange(-2.0, 4.1, 0.5)
v = np.arange(-2.0, 3.1, 0.5)
[x1, y1] = np.meshgrid(w, v)

h1 = np.exp(-x1**2-y1**2) + 0.5*np.exp(-(x1-1.5)**2 -2*y1**2) 
[gradhv, gradhu] = np.gradient(h1, 0.5)
ax1.quiver(x1, y1, gradhu, gradhv, width=0.003, angles='xy', scale_units='xy',\
           scale=2)
I would like to improve the visual presentation by making the plot larger (a zoomed in view) and making sure that the vector arrows do not cross contour lines (i.e. scaling the arrows so the size of the vector points are still clear but do not cross the contour lines.)

Would appreciate any help
Reply


Messages In This Thread
quiver plot scaling help - by StillAnotherDave - Oct-26-2020, 09:12 AM
RE: quiver plot scaling help - by StillAnotherDave - Oct-26-2020, 09:17 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Map plot does not align with quiver Gaben321 0 1,230 Jun-10-2022, 05:26 AM
Last Post: Gaben321
  Scaling random numbers within specific range schniefen 4 3,315 Oct-28-2019, 11:22 AM
Last Post: jefsummers
  Scaling elements of marix. pawlo392 1 2,222 May-16-2019, 11:37 PM
Last Post: michalmonday
  WaveCopy and Amplitude Scaling kgbprod 3 3,543 Apr-24-2019, 05:49 PM
Last Post: kgbprod

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020