Outline for histogram bars

Hi,

Is there an option to change the line style for the outline of histogram
bars? What I am looking for some something like the attached kernel
density plot. I can set different colors (attached) but this is not
very useful when printing in black and white.

Thanks,
Ted To

density-all-jobs-type2-overlay-paper.pdf (117 KB)

hist-all-jobs-type2-overlay.pdf (22.1 KB)

You should be able to specify linestyle='dashed' (or 'dashdot', or
'dotted') when you call hist().

I hope that helps!
Ben Root

···

On Tue, Nov 12, 2013 at 4:26 PM, Ted To <rainexpected@...3956...> wrote:

Hi,

Is there an option to change the line style for the outline of histogram
bars? What I am looking for some something like the attached kernel
density plot. I can set different colors (attached) but this is not
very useful when printing in black and white.

Thanks,
Ted To

Perfect! Many thanks! Seems to be an undocumented feature...

Out of curiosity, what is the rationale behind using 'dashed' and
'dashdot' instead of '--' and '-.'?

Ted To

···

On 11/12/2013 04:59 PM, Benjamin Root wrote:

On Tue, Nov 12, 2013 at 4:26 PM, Ted To <rainexpected@...3956... > <mailto:rainexpected@…3956…>> wrote:

    Hi,

    Is there an option to change the line style for the outline of histogram
    bars? What I am looking for some something like the attached kernel
    density plot. I can set different colors (attached) but this is not
    very useful when printing in black and white.

    Thanks,
    Ted To

You should be able to specify linestyle='dashed' (or 'dashdot', or
'dotted') when you call hist().

I hope that helps!
Ben Root

Perfect! Many thanks! Seems to be an undocumented feature...

Not undocumented. In the docs for hist(), it says that it accepts any
parameter that is used for Patch artists. This is also generally true for
many of the other plotting functions. They usually take any additional
keyword arguments that could be passed on to whatever the artist is that is
returned. This isn't a hard-and-fast rule, but it is true more often than
not.

Out of curiosity, what is the rationale behind using 'dashed' and
'dashdot' instead of '--' and '-.'?

This is an inadvertent oversight. I noted this in

Cheers!
Ben Root

···

On Tue, Nov 12, 2013 at 8:01 PM, Ted To <rainexpected@...3956...> wrote:

Thanks Ben!

I was wondering if you can help me with a related question. How does
one change the artist for the legend? Since I have a "step" histogram,
it would be nice to have the legend display lines rather than outlined
rectangles.

Thanks,
Ted

···

On 11/13/2013 09:35 AM, Benjamin Root wrote:

On Tue, Nov 12, 2013 at 8:01 PM, Ted To <rainexpected@...3956... > <mailto:rainexpected@…3956…>> wrote:

    Perfect! Many thanks! Seems to be an undocumented feature...

Not undocumented. In the docs for hist(), it says that it accepts any
parameter that is used for Patch artists. This is also generally true
for many of the other plotting functions. They usually take any
additional keyword arguments that could be passed on to whatever the
artist is that is returned. This isn't a hard-and-fast rule, but it is
true more often than not.

    Out of curiosity, what is the rationale behind using 'dashed' and
    'dashdot' instead of '--' and '-.'?

This is an inadvertent oversight. I noted this in
Inconsistent linestyle specifications between Line2D and Patch artists · Issue #2136 · matplotlib/matplotlib · GitHub

Cheers!
Ben Root

I am not really an expert on that topic, but this question (or one very
similar) has come up before. I think the answer is to use "Proxy Artists".
If you search for proxy artists in the documentation, you should find stuff
about that.

Cheers!
Ben Root

···

On Wed, Nov 13, 2013 at 8:16 PM, Ted To <rainexpected@...3956...> wrote:

Thanks Ben!

I was wondering if you can help me with a related question. How does
one change the artist for the legend? Since I have a "step" histogram,
it would be nice to have the legend display lines rather than outlined
rectangles.

Thanks,
Ted