[Matplotlib-users] Totaly new to matplotlib

Stevo stm6386 at gmail.com
Fri Feb 5 13:53:56 EST 2016


Guys,
This is where I am now - 
code 
def plot_durations(self,starts, stops, ax , **kwargs):
        if ax is None:
            ax = plt.gca()
        # Make the default alignment center, unless specified otherwise
        kwargs['align'] = kwargs.get('align', 'center')
    
        # Convert things to matplotlib's internal date format...
        starts, stops = mpl.dates.date2num(starts),
mpl.dates.date2num(stops)
    
        # Break things into start days and start times 
        start_times = starts % 1
        start_days = starts - start_times
        durations = stops - starts
        start_times += int(starts[0]) # So that we have a valid date...
    
        # Plot the bars
        artist = ax.bar(start_days, durations, bottom=start_times, **kwargs)
    
        # Tell matplotlib to treat the axes as dates...
        hfmt = dates.DateFormatter('%b %d')
        ax.xaxis.set_major_formatter(hfmt)
        ax.xaxis.set_major_locator(plt.MultipleLocator(1.0)) #a tick mark a
day
        ax.yaxis_date()
        ax.figure.autofmt_xdate()
        ax.invert_yaxis()
        plt.subplots_adjust (left = 0.1, bottom = 0.10, right = 0.97, top =
0.97, wspace = 0.20, hspace = 0.2)
        plt.show()
code

But for some reason I get inconsistent results for the y axis ..... 
<http://matplotlib.1069221.n5.nabble.com/file/n46719/figure_1-1.png> 
<http://matplotlib.1069221.n5.nabble.com/file/n46719/figure_4.png> 
I would prefer just hh:mm format if I could set it but have no idea why it
would the extra 0's ... the script wasnt restarted or anything just another
set of data used, the data looked identical in each case so I have no idea
what the change is caused by .... selecting and reselecting data just gave
the same results.
I could show the whole script if it helps but it gets quite complex.

Just learning and  loving Python
Stevo



--
View this message in context: http://matplotlib.1069221.n5.nabble.com/Totaly-new-to-matplotlib-tp46682p46719.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


More information about the Matplotlib-users mailing list