python - Plotting vector fields with two different methods (quiver / streamplot) resulting in plots that don't match - Matplotlib -


i'm trying plot vector flows in python, using matplotlib , i'm having trouble...

i'm trying compare 2 methods, quiver , streamplot(). i've read both documentations, wasn't able same results both.

i'm plotting vectors these 2 methods:

import matplotlib.pyplot plt import numpy  def plot_quiver(x_dim, y_dim, steps, vector_field_x, vector_field_y, file_path):     plt.figure()      x, y = numpy.mgrid[-x_dim/2:x_dim/2:steps*1j, -y_dim/2:y_dim/2:steps*1j]      plt.quiver(x, y, vector_field_x, vector_field_y)      plt.savefig(file_path + '.png')     plt.close()   def plot_streamlines(file_path, x_dim, y_dim, steps, vector_field_x, vector_field_y, scalar_field=none):     plt.figure()      y, x = numpy.mgrid[-x_dim/2:x_dim/2:steps*1j, -y_dim/2:y_dim/2:steps*1j]      plt.figure()      if scalar_field not none:         cs = plt.contour(x, y, scalar_field, extent=[-x_dim/2.0, x_dim/2.0, -y_dim/2.0, y_dim/2.0])         plt.clabel(cs, inline=1, fontsize=10)      # x, y : 1d arrays, evenly spaced grid.     # u, v : 2d arrays     # x , y-velocities. number of rows should match length of y, , number of columns should match x.     plt.streamplot(x, y, vector_field_x, vector_field_y, cmap=plt.cm.autumn)      plt.savefig(file_path + '.png')     plt.close() 

however, don't know how both plots "equal".

the first method plots image (which expecting):

enter image description here

and second 1 gives me this:

enter image description here

i don't know have match. tried every possible combination , got nothing...

and need both visualizations.

any appreciated. thank in advance.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -