Python matplotlib.pyplot.barbs() Examples

The following are 14 code examples of matplotlib.pyplot.barbs(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module matplotlib.pyplot , or try the search function .
Example #1
Source File: test_streamplot.py    From neural-network-animation with MIT License 5 votes vote down vote up
def test_streamplot_limits():
    ax = plt.axes()
    x = np.linspace(-5, 10, 20)
    y = np.linspace(-2, 4, 10)
    y, x = np.meshgrid(y, x)
    trans = mtransforms.Affine2D().translate(25, 32) + ax.transData
    plt.barbs(x, y, np.sin(x), np.cos(y), transform=trans)
    # The calculated bounds are approximately the bounds of the original data,
    # this is because the entire path is taken into account when updating the
    # datalim.
    assert_array_almost_equal(ax.dataLim.bounds, (20, 30, 15, 6),
                              decimal=1) 
Example #2
Source File: test_collections.py    From neural-network-animation with MIT License 5 votes vote down vote up
def test_barb_limits():
    ax = plt.axes()
    x = np.linspace(-5, 10, 20)
    y = np.linspace(-2, 4, 10)
    y, x = np.meshgrid(y, x)
    trans = mtransforms.Affine2D().translate(25, 32) + ax.transData
    plt.barbs(x, y, np.sin(x), np.cos(y), transform=trans)
    # The calculated bounds are approximately the bounds of the original data,
    # this is because the entire path is taken into account when updating the
    # datalim.
    assert_array_almost_equal(ax.dataLim.bounds, (20, 30, 15, 6),
                              decimal=1) 
Example #3
Source File: test_streamplot.py    From python3_ios with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_streamplot_limits():
    ax = plt.axes()
    x = np.linspace(-5, 10, 20)
    y = np.linspace(-2, 4, 10)
    y, x = np.meshgrid(y, x)
    trans = mtransforms.Affine2D().translate(25, 32) + ax.transData
    plt.barbs(x, y, np.sin(x), np.cos(y), transform=trans)
    # The calculated bounds are approximately the bounds of the original data,
    # this is because the entire path is taken into account when updating the
    # datalim.
    assert_array_almost_equal(ax.dataLim.bounds, (20, 30, 15, 6),
                              decimal=1) 
Example #4
Source File: test_collections.py    From python3_ios with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_barb_limits():
    ax = plt.axes()
    x = np.linspace(-5, 10, 20)
    y = np.linspace(-2, 4, 10)
    y, x = np.meshgrid(y, x)
    trans = mtransforms.Affine2D().translate(25, 32) + ax.transData
    plt.barbs(x, y, np.sin(x), np.cos(y), transform=trans)
    # The calculated bounds are approximately the bounds of the original data,
    # this is because the entire path is taken into account when updating the
    # datalim.
    assert_array_almost_equal(ax.dataLim.bounds, (20, 30, 15, 6),
                              decimal=1) 
Example #5
Source File: skewt.py    From pyMeteo with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def plot_wind_axes(axes):
  # plot wind barbs
  # TODO: also do storm-relative winds
  draw_wind_line(axes)
  axes.set_axis_off()
  axes.axis([-1,1,pbot,ptop]) 
Example #6
Source File: skewt.py    From pyMeteo with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def plot_wind(axes, z, p, u, v, x=0):  
  for i in np.arange(0,len(z),1):
    if (p[i] > pt_plot):
      plt.barbs(x,p[i],u[i],v[i], length=5, linewidth=.5) 
Example #7
Source File: skewt.py    From pyMeteo with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def plot_wind_barbs(axes, z, p, u, v):
    for i in np.arange(0,len(z)):
        if (p[i] > pt_plot):
            plt.barbs(0,p[i],u[i],v[i], length=5, linewidth=.5) 
Example #8
Source File: test_streamplot.py    From ImageFusion with MIT License 5 votes vote down vote up
def test_streamplot_limits():
    ax = plt.axes()
    x = np.linspace(-5, 10, 20)
    y = np.linspace(-2, 4, 10)
    y, x = np.meshgrid(y, x)
    trans = mtransforms.Affine2D().translate(25, 32) + ax.transData
    plt.barbs(x, y, np.sin(x), np.cos(y), transform=trans)
    # The calculated bounds are approximately the bounds of the original data,
    # this is because the entire path is taken into account when updating the
    # datalim.
    assert_array_almost_equal(ax.dataLim.bounds, (20, 30, 15, 6),
                              decimal=1) 
Example #9
Source File: test_collections.py    From ImageFusion with MIT License 5 votes vote down vote up
def test_barb_limits():
    ax = plt.axes()
    x = np.linspace(-5, 10, 20)
    y = np.linspace(-2, 4, 10)
    y, x = np.meshgrid(y, x)
    trans = mtransforms.Affine2D().translate(25, 32) + ax.transData
    plt.barbs(x, y, np.sin(x), np.cos(y), transform=trans)
    # The calculated bounds are approximately the bounds of the original data,
    # this is because the entire path is taken into account when updating the
    # datalim.
    assert_array_almost_equal(ax.dataLim.bounds, (20, 30, 15, 6),
                              decimal=1) 
Example #10
Source File: test_streamplot.py    From coffeegrindsize with MIT License 5 votes vote down vote up
def test_streamplot_limits():
    ax = plt.axes()
    x = np.linspace(-5, 10, 20)
    y = np.linspace(-2, 4, 10)
    y, x = np.meshgrid(y, x)
    trans = mtransforms.Affine2D().translate(25, 32) + ax.transData
    plt.barbs(x, y, np.sin(x), np.cos(y), transform=trans)
    # The calculated bounds are approximately the bounds of the original data,
    # this is because the entire path is taken into account when updating the
    # datalim.
    assert_array_almost_equal(ax.dataLim.bounds, (20, 30, 15, 6),
                              decimal=1) 
Example #11
Source File: test_collections.py    From coffeegrindsize with MIT License 5 votes vote down vote up
def test_barb_limits():
    ax = plt.axes()
    x = np.linspace(-5, 10, 20)
    y = np.linspace(-2, 4, 10)
    y, x = np.meshgrid(y, x)
    trans = mtransforms.Affine2D().translate(25, 32) + ax.transData
    plt.barbs(x, y, np.sin(x), np.cos(y), transform=trans)
    # The calculated bounds are approximately the bounds of the original data,
    # this is because the entire path is taken into account when updating the
    # datalim.
    assert_array_almost_equal(ax.dataLim.bounds, (20, 30, 15, 6),
                              decimal=1) 
Example #12
Source File: test_streamplot.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
def test_streamplot_limits():
    ax = plt.axes()
    x = np.linspace(-5, 10, 20)
    y = np.linspace(-2, 4, 10)
    y, x = np.meshgrid(y, x)
    trans = mtransforms.Affine2D().translate(25, 32) + ax.transData
    plt.barbs(x, y, np.sin(x), np.cos(y), transform=trans)
    # The calculated bounds are approximately the bounds of the original data,
    # this is because the entire path is taken into account when updating the
    # datalim.
    assert_array_almost_equal(ax.dataLim.bounds, (20, 30, 15, 6),
                              decimal=1) 
Example #13
Source File: test_collections.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
def test_barb_limits():
    ax = plt.axes()
    x = np.linspace(-5, 10, 20)
    y = np.linspace(-2, 4, 10)
    y, x = np.meshgrid(y, x)
    trans = mtransforms.Affine2D().translate(25, 32) + ax.transData
    plt.barbs(x, y, np.sin(x), np.cos(y), transform=trans)
    # The calculated bounds are approximately the bounds of the original data,
    # this is because the entire path is taken into account when updating the
    # datalim.
    assert_array_almost_equal(ax.dataLim.bounds, (20, 30, 15, 6),
                              decimal=1) 
Example #14
Source File: skewt.py    From pyMeteo with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
def plot(loc, z, th, p, qv, u, v, output, time = None, title = None):
  """Plots Skew-T/Log-P diagrapms with hodograph

  The helper functions above facilitate loading data from
  various formats and then call this function.  If you have
  data in another format or arrays of data in python already,
  then this is the function you want to use.

  :parameter loc: Location string
  :parameter z: z grid mesh (1D)
  :parameter time: Time string
  :parameter th: Potential temperature at z points
  :parameter p: Pressure at z points
  :parameter qv: Water vapor mixing ratio at z points
  :parameter u: u winds at z points
  :parameter v: v winds at z points
  :parameter title: Title for plot
  :parameter output: Filename to save plot to

  """
  fig = plt.figure(1, figsize=(10, 8), dpi=300, edgecolor='k')
  
  # sounding
  ax1 = plt.subplot(121)
  plot_sounding_axes(ax1)
  plot_sounding(ax1, z, th, p, qv, None, None)
  # hodograph
  ax2 = plt.subplot(222)
  plot_hodo_axes(ax2)
  plot_hodograph(ax2, z, u, v)
  # datablock
  ax3 = fig.add_subplot(224)
  try:
    plot_datablock(ax3, loc, z, time, th, p, qv, u, v, title)
  except:
      print("Error calcualting sounding stats, datablock omitted");
    
  # wind barbs
  ax4 = fig.add_subplot(132)
  plot_wind_axes(ax4)
  plot_wind_barbs(ax4,z,p,u,v)
  # legend
  ax5 = fig.add_subplot(4,4,15)
  plot_legend(ax5)

  
  # Adjust plot margins.
  plt.subplots_adjust(left=0.03, bottom=0.03, right=0.97, top=0.97, wspace=0.12, hspace=0.12)
  plt.savefig(output, dpi=300,bbox_inches=0)
  plt.close()