Note that there are some explanatory texts on larger screens.

plurals
  1. POPython matplotlib barbs/quiver map colors to different sets of values
    primarykey
    data
    text
    <p>I am trying to create a barb vector plot in matplotlib and map some colors to specific magnitudes: for example, to have vectors with magnitudes between 10 and 20 plotted as blue, and between 20 and 30 as rgb(0,15,40), and so on. The documentation for the barbs and quiver functions (they are similar) mentions the C input arg:</p> <hr> <p>barb(X, Y, U, V, C, **kw)</p> <p>Arguments:</p> <p>X, Y: The x and y coordinates of the barb locations (default is head of barb; see pivot kwarg)</p> <p>U, V: Give the x and y components of the barb shaft</p> <p>C: An optional array used to map colors to the barbs</p> <hr> <p>However, this is very vague, and after searching all over Google, I am no closer to understanding how to use this color array in specific ways. I managed to discover that by setting C equal to the array of vector magnitudes and specifying the "cmap" kwarg, it will map the barbs to the specified colormap, as in the example code below. However, this is not what I want. I want to control the colors of specific groups of magnitudes. Any help would be appreciated.</p> <p>Example code:</p> <pre><code>from matplotlib import pyplot as plt from numpy import arange,meshgrid,sqrt u,v = arange(-50,51,10),arange(-50,51,10) u,v = meshgrid(u,v) x,y = u,v C = sqrt(u**2 + v**2) plt.barbs(x,y,u,v,C,cmap=plt.cm.jet) plt.show() </code></pre> <p>Resulting plot image link: (sorry can't post images directly yet)</p> <p><a href="http://i49.tinypic.com/xombmc.jpg" rel="nofollow">http://i49.tinypic.com/xombmc.jpg</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload