Setting default histtype in matplotlib?
<p>Is there a way to configure the default argument for <code>histtype</code> of matplotlib's <code>hist()</code> function? The default behavior is to make bar-chart type histograms, which I basically <em>never</em> want to look at, since it is horrible for comparing multiple distributions that have significant overlap.</p>

<p>In case it's somehow relevant, the default behavior I would like to attain is to have <code>histtype='step'</code>.</p>

<p>Thank you for prompting me to look at this, as I much prefer <code>'step'</code> style histograms too! I solved this problem by going into the matplotlib source code. I use anaconda, so it was located in <code>anaconda/lib/site-packages/python2.7/matplotlib</code>.</p>

<p>To change the histogram style I edited two of the files. Assuming that the current directory is <code>matplotlib/</code>, then open up <code>axes/_axes.py</code> and locate the <code>hist()</code> function there (it's on line 5690 on my machine, matplotlib version 1.5.1). You should see the <code>histtype</code> argument there. Change this to <code>'step'</code>.</p>

<p>Now open up <code>pyplot.py</code> and again locate the <code>hist()</code> function and make the same change to the <code>histtype</code> argument (line 2943 in version 1.5.1 and on my machine). There is a comment about not editing this function, but I only found this to be an issue when I didn't also edit <code>axes/_axes.py</code> as well.</p>

<p>This worked for me! Another alternative would be just to write a wrapper around <code>hist()</code> yourself that changes the default argument. </p>

python matplotlib data-analysis