[Matplotlib-users] Totaly new to matplotlib

Stevo stm6386 at gmail.com
Thu Feb 4 13:18:14 EST 2016


Paul,
Sorry for the delay, I had trouble getting the original post accepted .... I
replied on the 29th of Jan.
Since the previous post I have found some code that almost does what I
wanted but as always when you get a little more of something you lost it
somewhere else. 
what I have now is displaying -
<http://matplotlib.1069221.n5.nabble.com/file/n46712/figure_1-1.png> 
<http://matplotlib.1069221.n5.nabble.com/file/n46712/figure_1.png> 

the code to create the graph is  -
code
def plot_durations(self,starts, stops, ax=None, **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...
        ax.xaxis_date()
        ax.yaxis_date()
        ax.figure.autofmt_xdate()
        plt.show()
code

Issues or things id like to or am trying to change :-
The code is the same for both graphs but one shows times for the x axis and
not date (must be due to the data range) id like it to show only dates on
the x axis but also every date, not missing any .. as the previous version
did.

I would like the y axis to display time am at the top pm at the bottom as
the previous version did.  

there are a few other things but one step at a time I guess, I have tried to
copy lines from the older version to the new one but without success.

Cheers
Stevo




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


More information about the Matplotlib-users mailing list