Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder3.xlned.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.010 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'string': 0.09; 'immutable': 0.09; 'key.': 0.09; 'api': 0.11; 'cc:addr:python- list': 0.11; '--\xc2\xa0': 0.16; 'cc:name:python list': 0.16; 'hashable': 0.16; 'mutable': 0.16; 'skip:" 100': 0.16; 'symbols': 0.16; 'tuples,': 0.16; 'typeerror:': 0.16; 'types,': 0.16; 'unhashable': 0.16; '\xc2\xa0you': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'email addr:gmail.com>': 0.22; 'cc:addr:python.org': 0.22; 'error': 0.23; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'idea': 0.28; 'skip:p 30': 0.29; 'am,': 0.29; 'message- id:@mail.gmail.com': 0.30; '(which': 0.31; 'went': 0.31; 'easier': 0.31; 'etc.).': 0.31; 'file': 0.32; 'lists': 0.32; 'skip:c 30': 0.32; 'option': 0.32; 'fri,': 0.33; 'basic': 0.35; 'received:google.com': 0.35; 'thanks': 0.36; 'should': 0.36; 'jason': 0.38; 'university': 0.39; 'act': 0.63; 'great': 0.65; 'to:addr:gmail.com': 0.65; '20,': 0.68; 'therefore': 0.72; 'float,': 0.84; 'happening?': 0.84; 'hatch': 0.84; 'response,': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=wpWIHoT9wG5Njsfpli3u5cFzmHseg9Ffcd+KUyGSVKE=; b=alUR7eW9WxgULVsiFwlybk02k6DMENPdUaJoZprEsxv1J2VV/NqX4C11wLK4W886nw fQT8WR+AHHdryI6794q+pL4AmU5C3CFqq0wuJOpjSAobJkSyIhK1H/L5aahT8awB6tly XAtKGbnzHIIKsJ2/QSR+dJP3VXRp+Fgz25kd8w8wkeRKDqKDuyVQ2vUROXGVQRbP8z2q ipI/Gf2ozET9q5d3V4o8rBVZ61wsBncucddgQfw23N/7Rm2YeHmuGx4GxaDhPqsN70Q4 zRAJi69TZajMblAZHZtk2S4keHd23F++lYCuBqjUFRFnzAn9Dx7a+FeF9xMzU1CPvvCh 4XcA== MIME-Version: 1.0 X-Received: by 10.236.137.198 with SMTP id y46mr6029517yhi.31.1403275961046; Fri, 20 Jun 2014 07:52:41 -0700 (PDT) In-Reply-To: <83defcb1-70ef-437f-87df-9f8c8164fa92@googlegroups.com> References: <83defcb1-70ef-437f-87df-9f8c8164fa92@googlegroups.com> Date: Fri, 20 Jun 2014 10:52:40 -0400 Subject: Re: Matplotlib Colouring outline of histogram From: Jason Swails To: Jamie Mitchell Content-Type: multipart/alternative; boundary=20cf303a30572e1aa204fc45a50f Cc: python list X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 100 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1403276280 news.xs4all.nl 2906 [2001:888:2000:d::a6]:46413 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:73462 --20cf303a30572e1aa204fc45a50f Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Fri, Jun 20, 2014 at 10:27 AM, Jamie Mitchell < jamiemitchell1604@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=3D10,hatch=3D['*']) > > When it comes to plt.show() I get the following error message: > =E2=80=8B[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 =3D 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).=E2=80=8B 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=3D'*') HTH, Jason --=20 Jason M. Swails BioMaPS, Rutgers University Postdoctoral Researcher --20cf303a30572e1aa204fc45a50f Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

<= /div>


On Fri, = Jun 20, 2014 at 10:27 AM, Jamie Mitchell <jamiemitchell1604@gmai= l.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=3D10,hatch=3D['*'])

When it comes to plt.show() I get the following error message:
=E2= =80=8B[snip]

=C2=A0 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
=C2=A0 =C2=A0 hatch_path =3D cls._hatch_dict.get((hatchpattern, density)) TypeError: unhashable type: 'list'

Do you have any idea why this is happening?

=
lists are mutable t= ypes, so they are not hashable (and therefore cannot be used as dictionary = keywords).=E2=80=8B =C2=A0You need an immutable type (which _is_ hashable) = to act as a dictionary key. =C2=A0Like strings, tuples, and basic number ty= pes (int, float, etc.).

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

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

HTH,
Jason

--=C2=A0
Jason M. Swails
BioMaPS,
Rutgers University
Postdoctoral = Researcher
--20cf303a30572e1aa204fc45a50f--