|
From: Paul H. <pmh...@gm...> - 2012-09-25 06:43:21
|
> On Mon, Sep 24, 2012 at 12:21 AM, Paul Tremblay <pau...@gm...> > wrote: >> >> Here is my example of a Pareto chart. >> >> For an explanation of a Pareto chart: >> >> http://en.wikipedia.org/wiki/Pareto_chart >> >> Could I get this chart added to the matplolib gallery? >> >> >> Thanks >> >> Paul >> > On 9/24/12 4:40 PM, Benjamin Root wrote: > Your code looks overly complicated. You shouldn't have to be doing the > connection to the ylim_changed event, I don't think. I think your main > problem is that you are calling ax1.plot instead of ax2.plot. > > I am not against adding more examples to the gallery, but this would have to > be cleaned up before it gets included. > > Ben Root On Mon, Sep 24, 2012 at 5:50 PM, Paul Tremblay <pau...@gm...> wrote: > I took my example from the matplotlib pages itself: > > http://matplotlib.org/examples/api/fahrenheit_celcius_scales.html > > If you know a better way, please show me. > > P. Paul, That example is an overly complicated template for making a pareto chart. Here's how I'd do it: # data defects = [0, 32, 22, 15, 5, 2] labels = ['', 'vertical', 'horizontal', 'behind', 'left area', 'other'] # axes fig, ax1 = plt.subplots() ax2 = ax1.twinx() # plotting ax1.bar(np.arange(len(defects))-0.4, defects, zorder=0, alpha=0.5) ax2.plot(np.cumsum(defects), linestyle='-', color='k', linewidth=2, zorder=5) # formatting ax1.set_xticks(np.arange(len(defects))) ax1.set_xticklabels(labels) ax1.set_ylabel('Defects') ax2.set_ylabel('Percentage') plt.show() |