histogram hatching


I’ve been generating many overlapping histograms with different hatch styles over the past month and a half. But now that I want to use them for a paper; I see that the hatch lines are illegibly faint in print. Is there a way to make them thicker?

Any other suggestions for making overlapping histogram graphs legible for print? (I’ve got two classes that should each have its own legend, but they overlap). I’ve tried different hatching styles and also using transparency (hist(…,alpha=float)), but transparency has the undesired effect making the bar edges transparent and not just the fill.
for example:

if not(hatch):
coudy_handle=hist(cloudy_data, cloudy_bins, facecolor = ‘1.0’,alpha=0.2) #makes edges to
clear_handle=hist(clear_data, clear_bins, facecolor = ‘0.8’, alpha=1.0)
coudy_handle=hist(cloudy_data, cloudy_bins, hatch=’||’, fill=False) #fill lines are too faint
clear_handle=hist(clear_data, clear_bins, hatch=’–’, fill=False)

legend((clear_handle[2][0],coudy_handle[2][0]), (“Cloudy”,“Clear”), loc=‘best’)

My current solution is to fill the back class (the one I plot first) and not fill the top one, but this is not general, i.e. I have to adjust it depending on how the classes overlap to ensure that the top class is never completely inside the back one.

Thanks for the help,


----- Original Message ----
From: Michael Droettboom <mdroe@…86…>
To: izak marais <izakmarais@…9…>
Cc: matplotlib-users@lists.sourceforge.net
Sent: Thursday, June 26, 2008 2:33:11 PM
Subject: Re: [Matplotlib-users] histogram hatching

Thanks for pointing this out. This is now fixed in SVN.


izak marais wrote:

The vertical and horizontal hatch styles are swapped. According to
the docs:
> - vertical
- - horizontal
but ‘|’ gives horizontal and ‘-’ vertical patterns. The reaming styles
appear to work correctly.

----- Original Message ----
From: John Hunter <jdh2358@…287…>
To: izak marais <izakmarais@…9…>
Cc: matplotlib-users@lists.sourceforge.net
Sent: Wednesday, June 25, 2008 3:49:56 PM
Re: [Matplotlib-users] histogram hatching

On Wed, Jun 25, 2008 at 6:05 AM, izak marais <izakmarais@…9… > mailto:izakmarais@...9...> wrote:


I see there is a “hatch: unknown” kwarg mentioned in the hist()
documentation. Can anyone shed some light on how to use this please? I
assume it might be used to generate monochrome rectangles with
differentiating hatched fills?

The rectangles generates by “hist” are matplotlib.patch.Rectangle
instances, and the “hatch” property is controlled by the “set_hatch”
method. Here is the docstring which should tell you most everything
you need to know. Note the caveat at the end that it is
currently supported on postscript – patches for other backends much

def set_hatch(self, h):
Set the hatching pattern

   hatch can be one of::

     /  - diagonal hatching
     \  - back diagonal
     >  - vertical
     -  - horizontal
     #  - crossed
     x  - crossed diagonal

   Letters can be combined, in which case all the specified
   hatchings are done.  If same letter repeats, it increases the
   density of hatching in that direction.


   1. Hatching is supported in the PostScript backend only.

   2. Hatching is done with solid black lines of width 0.

Check out the new SourceForge.net Marketplace.
It’s the best place to buy or sell services for
just about anything Open Source.

Matplotlib-users mailing list

Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA