[Tutor] Overlay Quiver Plot on Contours

Danny Yoo dyoo at hashcollision.org
Tue Jan 27 02:45:30 CET 2015


>> and I am getting this error:
>>
>> TypeError: You must first set_array for mappable
>>
>> Can anyone provide guidance on how you overlay quiver plots on top of
>> contours?
>
>
> This list is for newcomers to Python and its standard
> library. This looks like a fairly specific SciPy/Numpy,
> and especially matplotlib type question.
>
> You would probably be better off asking on the SciPy
> forums/lists.


Agree with Alan.  You'll get better help from people who know the
library.  Very few of us here do things with SciPy.


Just to add: please add more context to your error message reports,
regardless of who you're asking help from.

To include the single line:

#######
TypeError: You must first set_array for mappable
#######

is somewhat helpful: it does have some information.


But unless you've suppressed error reporting, you should be getting
significantly more information from the error message.

I did a quick web search for your error message, and came up with:

    http://stackoverflow.com/questions/6600579/colorbar-for-matplotlib-plot-surface-command

which might look reasonably close to what you're seeing.  And note
how, in that message, they include a full stack trace of the problem,
which looks like:

#########################################################################
Traceback (most recent call last):
  File "<ipython console>", line 1, in <module>
  File "C:\Python26\lib\site-packages\spyderlib\widgets\externalshell\startup.py",
line 122, in runfile
    execfile(filename, glbs)
 File "C:\Documents and Settings\mramacha\My
Documents\Python\Candela\test.py", line 22, in <module>
    fig.colorbar(surf, shrink=0.5, aspect=5)
  File "C:\Python26\lib\site-packages\matplotlib\figure.py", line
1104, in colorbar
    cb = cbar.Colorbar(cax, mappable, **kw)
  File "C:\Python26\lib\site-packages\matplotlib\colorbar.py", line
706, in __init__
    mappable.autoscale_None() # Ensure mappable.norm.vmin, vmax
  File "C:\Python26\lib\site-packages\matplotlib\cm.py", line 261, in
autoscale_None
    raise TypeError('You must first set_array for mappable')
TypeError: You must first set_array for mappable
#########################################################################

This is the sort of thing that is a *joy* to see when debugging.  If I
don't have a good stack trace when trying to diagnose a problem, I am
not as happy, because I don't have my hand on any useful context to
work with.  It's like working in the dark.


In your case, I can't tell for sure if your scenario matches the
above, because the error message information content is low enough to
raise doubts.


More information about the Tutor mailing list