Matplotlib Colouring outline of histogram

Jason Swails jason.swails at gmail.com
Fri Jun 20 10:52:40 EDT 2014


On Fri, Jun 20, 2014 at 10:27 AM, Jamie Mitchell <
jamiemitchell1604 at gmail.com> wrote:

>
> That's great Jason thanks for the detailed response, I went with the
> easier option 1!
>
> I am also trying to put hatches on my histograms like so:
>
> plt.hist(dataset,bins=10,hatch=['*'])
>
> When it comes to plt.show() I get the following error message:
> ​[snip]
>
>   File
> "/usr/local/sci/lib/python2.7/site-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/path.py",
> line 888, in hatch
>     hatch_path = cls._hatch_dict.get((hatchpattern, density))
> TypeError: unhashable type: 'list'
>
> Do you have any idea why this is happening?
>

lists are mutable types, so they are not hashable (and therefore cannot be
used as dictionary keywords).​  You need an immutable type (which _is_
hashable) to act as a dictionary key.  Like strings, tuples, and basic
number types (int, float, etc.).

The hatch should be a string (allowable symbols are given in the API
documentation).  So try

plt.hist(dataset, bins, hatch='*')

HTH,
Jason

-- 
Jason M. Swails
BioMaPS,
Rutgers University
Postdoctoral Researcher
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20140620/d2577dfa/attachment.html>


More information about the Python-list mailing list