Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #73462

Re: Matplotlib Colouring outline of histogram

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 <jason.swails@gmail.com>
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&gt;': 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 <ae0491e6-70de-4cc3-aea4-8922f72e17b8@googlegroups.com> <mailman.11167.1403272031.18130.python-list@python.org> <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 <jason.swails@gmail.com>
To Jamie Mitchell <jamiemitchell1604@gmail.com>
Content-Type multipart/alternative; boundary=20cf303a30572e1aa204fc45a50f
Cc python list <python-list@python.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.11169.1403276280.18130.python-list@python.org> (permalink)
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

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

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=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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Matplotlib Colouring outline of histogram Jamie Mitchell <jamiemitchell1604@gmail.com> - 2014-06-20 01:10 -0700
  Re: Matplotlib Colouring outline of histogram Jason Swails <jason.swails@gmail.com> - 2014-06-20 09:47 -0400
    Re: Matplotlib Colouring outline of histogram Jamie Mitchell <jamiemitchell1604@gmail.com> - 2014-06-20 07:27 -0700
      Re: Matplotlib Colouring outline of histogram Jason Swails <jason.swails@gmail.com> - 2014-06-20 10:52 -0400
  Re: Matplotlib Colouring outline of histogram Jamie Mitchell <jamiemitchell1604@gmail.com> - 2014-06-20 08:10 -0700

csiph-web