Totaly new to matplotlib

Hi guys,
Im new to Python and matplotlib, I have a need to try and make a chart of
some kind so was just searching around and looking at Plotly but it looks so
complicated then I found the matplotlib site and was quite amazed how simple
the code was to create some really incredible looking plots.
Unfortunately none of the examples are quite what Im needing but Im guessing
that is possible to create what i need as by the look of the gallery it
would be a breeze for you experienced guys.
The data I want to plot is durations during days (its a sort of working
time/clock machine plot).... I imagine it to be a cross between the
histogram_path_demo and one of those candle stick type ones, x being the
day's time range centre of range being say lunchtime and each bar showing
the shift start and end (centred on 12 lunchtime) but allowing for the bar
to be broken when ever clocked in or out within that day.. if that makes
sense ?
Im very unsure even where to start so any pointers and advise would be
greatly appreciated.

Cheers
Stevo

···

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

If it helps the data I have is in the form of a list, each item in the list
has [date&time, duration/timedelta] excerpt below.

['14/05/2015 10:06', datetime.timedelta(0, 4440), '14/05/2015 11:25',
datetime.timedelta(0, 3480), '14/05/2015 12:27', datetime.timedelta(0,
6000), '14/05/2015 14:18', datetime.timedelta(0, 7200), '14/05/2015
16:22', datetime.timedelta(0, 4800), '15/05/2015 06:51',
datetime.timedelta(0, 6960), '15/05/2015 08:51', datetime.timedelta(0,
1980), '15/05/2015 09:28', datetime.timedelta(0, 3000), '15/05/2015
11:43', datetime.timedelta(0, 3480), '15/05/2015 14:24',
datetime.timedelta(0, 2760), '15/05/2015 15:12', datetime.timedelta(0,
3120)]

Its just a matter of how best to display it visually.

Cheers
Steve

···

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

Hey Stevo,

You're gonna have to help us out a little more. Provide some links to what
you're trying to achieve (whether in the MPL gallery or not), and include a
minimal working example of the code that you've tried,
-paul

···

On Wed, Jan 27, 2016 at 3:44 PM, Stevo <stm6386 at gmail.com> wrote:

If it helps the data I have is in the form of a list, each item in the list
has [date&time, duration/timedelta] excerpt below.

['14/05/2015 10:06', datetime.timedelta(0, 4440), '14/05/2015 11:25',
datetime.timedelta(0, 3480), '14/05/2015 12:27', datetime.timedelta(0,
6000), '14/05/2015 14:18', datetime.timedelta(0, 7200), '14/05/2015
16:22', datetime.timedelta(0, 4800), '15/05/2015 06:51',
datetime.timedelta(0, 6960), '15/05/2015 08:51', datetime.timedelta(0,
1980), '15/05/2015 09:28', datetime.timedelta(0, 3000), '15/05/2015
11:43', datetime.timedelta(0, 3480), '15/05/2015 14:24',
datetime.timedelta(0, 2760), '15/05/2015 15:12', datetime.timedelta(0,
3120)]

Its just a matter of how best to display it visually.

Cheers
Steve

--
View this message in context:
http://matplotlib.1069221.n5.nabble.com/Totaly-new-to-matplotlib-tp46682p46683.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
Matplotlib-users Info Page

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20160129/94ffb4db/attachment.html&gt;

Paul,
Thanks for the reply, since my last post I've been working on this lots and
have a working script.
Pictures below, took me a while to get it working but it does. the main
issue I have with it is that as you can see from the pictures when the time
periods for a day are stacked for some reason the are all on a slant
(presumably time related)
<http://matplotlib.1069221.n5.nabble.com/file/n46699/figure_2.png>
<http://matplotlib.1069221.n5.nabble.com/file/n46699/figure_3.png>

Is there a way to straighten it all up ?
as in the code below it now receives ['3/6/2013' '11:30:00' '14:30:00'
'3:00:00'] for each event, the basics are there but its not very pretty yet.
Im still trying to figure out how I got it working quite an achievement for
me if i#m honest.

def createGraph(self):
        #data appears like so:
        #date,init time,end time,elapsed time
        #3/6/2013,4:30:00,8:45:00,4:15:00
        try:
            data = np.array(self.graphList1)
            #print data[1]
            #['3/6/2013' '11:30:00' '14:30:00' '3:00:00']
            day = data[:,0]
            hour1 = data[:,1]
            hour2 = data[:,2]
            hour3 = data[:,3]
            
            inittime = [a+' '+b for a,b in zip(day, hour1)]
            elapsedtime = [a+' '+b for a,b in zip(day, hour3)]
            #print inittime
            # 3/6/2013 4:30:00
        except Exception, e:
            print e
        
        #from [1], " I gave up after trying a few different ways, and
resorted to a very easy workaround.
        # Plot the times as integer minutes : 0 being midnight, 60 = 1am ...
which is 24hr * 60. "
        def dt2m(dt):
            return (dt.hour*60) + dt.minute
            
        print inittime[0]
        
        inittime = [datetime.datetime.strptime(foo,'%d/%m/%Y %H:%M') for foo
in inittime]
        elapsedtime = [datetime.datetime.strptime(foo,'%d/%m/%Y %H:%M:%S')
for foo in elapsedtime]
        #os.remove('chart.csv')
        # [1] "Then format the Y axis as Hour:Minute using a custom
formatter:"
        def m2hm(x, i):
            h = int(x/60)
            m = int(x%60)
            return '%(h)02d:%(m)02d' % {'h':h,'m':m}
        
        inittime_mins = [dt2m(foo) for foo in inittime]
        elaptime_mins = [dt2m(foo) for foo in elapsedtime]
        #heights = [60,120,240]
        #print inittime_mins
        
        fig = plt.figure(figsize=(12,7)) #figsize in inches
        ax = fig.add_subplot(1, 1, 1)
        ax.bar(inittime,elaptime_mins,bottom=inittime_mins)
        
        plt.xticks(rotation='45')
        
        # matplotlib date format object
        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.set_ylim([20*60, 5*60])
        ax.yaxis.set_major_formatter(ff(m2hm))
        ax.yaxis.set_major_locator(plt.MultipleLocator(60)) #a tick mark an
hour
        plt.subplots_adjust (left = 0.06, bottom = 0.10, right = 0.97, top =
0.97, wspace = 0.20, hspace = 0.20)
        plt.show()

···

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

Paul,
Thanks for the reply, since my last post I've been working on this lots and
have a working script.
Pictures below, took me a while to get it working but it does. the main
issue I have with it is that as you can see from the pictures when the time
periods for a day are stacked for some reason the are all on a slant
(presumably time related)
<http://matplotlib.1069221.n5.nabble.com/file/n46709/figure_2.png>
<http://matplotlib.1069221.n5.nabble.com/file/n46709/figure_3.png>

Is there a way to straighten it all up ?
as in the script below it now receives ['3/6/2013' '11:30:00' '14:30:00'
'3:00:00'] for each event, the basics are there but its not very pretty yet.
Im still trying to figure out how I got it working quite an achievement for
me if i#m honest.
code
def createGraph(self):
        #data appears like so:
        #date,init time,end time,elapsed time
        #3/6/2013,4:30:00,8:45:00,4:15:00
        try:
            data = np.array(self.graphList1)
            #print data[1]
            #['3/6/2013' '11:30:00' '14:30:00' '3:00:00']
            day = data[:,0]
            hour1 = data[:,1]
            hour2 = data[:,2]
            hour3 = data[:,3]
           
            inittime = [a+' '+b for a,b in zip(day, hour1)]
            elapsedtime = [a+' '+b for a,b in zip(day, hour3)]
            #print inittime
            # 3/6/2013 4:30:00
        except Exception, e:
            print e
       
        #from [1], " I gave up after trying a few different ways, and
resorted to a very easy workaround.
        # Plot the times as integer minutes : 0 being midnight, 60 = 1am ...
which is 24hr * 60. "
        def dt2m(dt):
            return (dt.hour*60) + dt.minute
           
        print inittime[0]
       
        inittime = [datetime.datetime.strptime(foo,'%d/%m/%Y %H:%M') for foo
in inittime]
        elapsedtime = [datetime.datetime.strptime(foo,'%d/%m/%Y %H:%M:%S')
for foo in elapsedtime]
        #os.remove('chart.csv')
        # [1] "Then format the Y axis as Hour:Minute using a custom
formatter:"
        def m2hm(x, i):
            h = int(x/60)
            m = int(x%60)
            return '%(h)02d:%(m)02d' % {'h':h,'m':m}
       
        inittime_mins = [dt2m(foo) for foo in inittime]
        elaptime_mins = [dt2m(foo) for foo in elapsedtime]
        #heights = [60,120,240]
        #print inittime_mins
       
        fig = plt.figure(figsize=(12,7)) #figsize in inches
        ax = fig.add_subplot(1, 1, 1)
        ax.bar(inittime,elaptime_mins,bottom=inittime_mins)
       
        plt.xticks(rotation='45')
       
        # matplotlib date format object
        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.set_ylim([20*60, 5*60])
        ax.yaxis.set_major_formatter(ff(m2hm))
        ax.yaxis.set_major_locator(plt.MultipleLocator(60)) #a tick mark an
hour
        plt.subplots_adjust (left = 0.06, bottom = 0.10, right = 0.97, top =
0.97, wspace = 0.20, hspace = 0.20)
        plt.show()code

···

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

Paul,
Thanks for the reply, since my last post I've been working on this lots and
have a working script.
Pictures below, took me a while to get it working but it does. the main
issue I have with it is that as you can see from the pictures when the time
periods for a day are stacked for some reason the are all on a slant
(presumably time related)
<http://matplotlib.1069221.n5.nabble.com/file/n46710/figure_2.png>
<http://matplotlib.1069221.n5.nabble.com/file/n46710/figure_3.png>

Is there a way to straighten it all up ?
as in the script below it now receives ['3/6/2013' '11:30:00' '14:30:00'
'3:00:00'] for each event, the basics are there but its not very pretty yet.
Im still trying to figure out how I got it working quite an achievement for
me if i#m honest.
code
def createGraph(self):
        #data appears like so:
        #date,init time,end time,elapsed time
        #3/6/2013,4:30:00,8:45:00,4:15:00
        try:
            data = np.array(self.graphList1)
            #print data[1]
            #['3/6/2013' '11:30:00' '14:30:00' '3:00:00']
            day = data[:,0]
            hour1 = data[:,1]
            hour2 = data[:,2]
            hour3 = data[:,3]
           
            inittime = [a+' '+b for a,b in zip(day, hour1)]
            elapsedtime = [a+' '+b for a,b in zip(day, hour3)]
            #print inittime
            # 3/6/2013 4:30:00
        except Exception, e:
            print e
       
        #from [1], " I gave up after trying a few different ways, and
resorted to a very easy workaround.
        # Plot the times as integer minutes : 0 being midnight, 60 = 1am ...
which is 24hr * 60. "
        def dt2m(dt):
            return (dt.hour*60) + dt.minute
           
        print inittime[0]
       
        inittime = [datetime.datetime.strptime(foo,'%d/%m/%Y %H:%M') for foo
in inittime]
        elapsedtime = [datetime.datetime.strptime(foo,'%d/%m/%Y %H:%M:%S')
for foo in elapsedtime]
        #os.remove('chart.csv')
        # [1] "Then format the Y axis as Hour:Minute using a custom
formatter:"
        def m2hm(x, i):
            h = int(x/60)
            m = int(x%60)
            return '%(h)02d:%(m)02d' % {'h':h,'m':m}
       
        inittime_mins = [dt2m(foo) for foo in inittime]
        elaptime_mins = [dt2m(foo) for foo in elapsedtime]
        #heights = [60,120,240]
        #print inittime_mins
       
        fig = plt.figure(figsize=(12,7)) #figsize in inches
        ax = fig.add_subplot(1, 1, 1)
        ax.bar(inittime,elaptime_mins,bottom=inittime_mins)
       
        plt.xticks(rotation='45')
       
        # matplotlib date format object
        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.set_ylim([20*60, 5*60])
        ax.yaxis.set_major_formatter(ff(m2hm))
        ax.yaxis.set_major_locator(plt.MultipleLocator(60)) #a tick mark an
hour
        plt.subplots_adjust (left = 0.06, bottom = 0.10, right = 0.97, top =
0.97, wspace = 0.20, hspace = 0.20)
        plt.show()code

···

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

Paul,
Thanks for the reply, since my last post I've been working on this lots and
have a working script.
Pictures below, took me a while to get it working but it does. the main
issue I have with it is that as you can see from the pictures when the time
periods for a day are stacked for some reason the are all on a slant
(presumably time related)
<http://matplotlib.1069221.n5.nabble.com/file/n46711/figure_2.png>
<http://matplotlib.1069221.n5.nabble.com/file/n46711/figure_3.png>

Is there a way to straighten it all up ?
as in the script below it now receives ['3/6/2013' '11:30:00' '14:30:00'
'3:00:00'] for each event, the basics are there but its not very pretty yet.
Im still trying to figure out how I got it working quite an achievement for
me if i#m honest.
code
def createGraph(self):
        #data appears like so:
        #date,init time,end time,elapsed time
        #3/6/2013,4:30:00,8:45:00,4:15:00
        try:
            data = np.array(self.graphList1)
            #print data[1]
            #['3/6/2013' '11:30:00' '14:30:00' '3:00:00']
            day = data[:,0]
            hour1 = data[:,1]
            hour2 = data[:,2]
            hour3 = data[:,3]
           
            inittime = [a+' '+b for a,b in zip(day, hour1)]
            elapsedtime = [a+' '+b for a,b in zip(day, hour3)]
            #print inittime
            # 3/6/2013 4:30:00
        except Exception, e:
            print e
       
        #from [1], " I gave up after trying a few different ways, and
resorted to a very easy workaround.
        # Plot the times as integer minutes : 0 being midnight, 60 = 1am ...
which is 24hr * 60. "
        def dt2m(dt):
            return (dt.hour*60) + dt.minute
           
        print inittime[0]
       
        inittime = [datetime.datetime.strptime(foo,'%d/%m/%Y %H:%M') for foo
in inittime]
        elapsedtime = [datetime.datetime.strptime(foo,'%d/%m/%Y %H:%M:%S')
for foo in elapsedtime]
        #os.remove('chart.csv')
        # [1] "Then format the Y axis as Hour:Minute using a custom
formatter:"
        def m2hm(x, i):
            h = int(x/60)
            m = int(x%60)
            return '%(h)02d:%(m)02d' % {'h':h,'m':m}
       
        inittime_mins = [dt2m(foo) for foo in inittime]
        elaptime_mins = [dt2m(foo) for foo in elapsedtime]
        #heights = [60,120,240]
        #print inittime_mins
       
        fig = plt.figure(figsize=(12,7)) #figsize in inches
        ax = fig.add_subplot(1, 1, 1)
        ax.bar(inittime,elaptime_mins,bottom=inittime_mins)
       
        plt.xticks(rotation='45')
       
        # matplotlib date format object
        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.set_ylim([20*60, 5*60])
        ax.yaxis.set_major_formatter(ff(m2hm))
        ax.yaxis.set_major_locator(plt.MultipleLocator(60)) #a tick mark an
hour
        plt.subplots_adjust (left = 0.06, bottom = 0.10, right = 0.97, top =
0.97, wspace = 0.20, hspace = 0.20)
        plt.show()code

···

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

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.

OK first step forward ..... inverted the y axis with ...
'plt.gca().invert_yaxis()'

···

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

better: `ax.invert_yaxis()`?

You have no guarantee that `plt.gca()` is the same as the `ax` parameter
that you have in your function.

Ben Root

···

On Thu, Feb 4, 2016 at 3:49 PM, Stevo <stm6386 at gmail.com> wrote:

OK first step forward ..... inverted the y axis with ...
'plt.gca().invert_yaxis()'

--
View this message in context:
http://matplotlib.1069221.n5.nabble.com/Totaly-new-to-matplotlib-tp46682p46713.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
Matplotlib-users Info Page

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20160204/dee1748d/attachment-0001.html&gt;

Ben,

Please for give me for not being experienced enough in python to understand
the significance of the difference of that but I have changed it .. thank
you.

Loving Python
Stevo

···

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

Ben,

Please for give me for not being experienced enough in python to understand
the significance of the difference of that but I have changed it .. thank
you.

Loving Python
Stevo

···

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

Stevo,

Don't worry, we all started from somewhere, but it is important to
understand the distinction. This has nothing to do with python, by the way.
`plt.gca()` returns the "current"/"active" axes object. Meanwhile, your
function does its plotting on an axes object called "ax". These may or may
not be the same thing -- you just simply don't know. So, your function
should continue to perform its plotting commands on the "ax" variable, not
on the result from `plt.gca()`.

Note though, it is perfectly valid what you have in the beginning of the
function what called `plt.gca()` if "ax" was not supplied by the user. But
you should continue to use "ax" throughout the function so that all actions
happen to the same variable.

I hope that makes it clearer.

Ben Root

···

On Thu, Feb 4, 2016 at 5:00 PM, Stevo <stm6386 at gmail.com> wrote:

Ben,

Please for give me for not being experienced enough in python to understand
the significance of the difference of that but I have changed it .. thank
you.

Loving Python
Stevo

--
View this message in context:
http://matplotlib.1069221.n5.nabble.com/Totaly-new-to-matplotlib-tp46682p46716.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
Matplotlib-users Info Page

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20160204/19a68fb5/attachment.html&gt;

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.

Looks like you should set the y-formatter in a similar fashion as you do
the the x-formatter:

hrmin_fmt = dates.DateFormatter('%H %M')
ax.yaxis.set_major_formatter(hrmin_fmt)

···

On Fri, Feb 5, 2016 at 10:53 AM, Stevo <stm6386 at gmail.com> wrote:

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&gt;
<http://matplotlib.1069221.n5.nabble.com/file/n46719/figure_4.png&gt;
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.
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
Matplotlib-users Info Page

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20160205/0c8dcfa6/attachment.html&gt;

Paul,

That does it perfectly, I had tried something similar myself but wasnt sure
what I was doing and obviously got it wrong.

Works perfect now.

Very thankful

Stevo

···

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

One thing I have noticed that seems very very odd to me is that for no
apparent reason I get one odd darker blue coloured line on some of the
graphs.

weird !

<http://matplotlib.1069221.n5.nabble.com/file/n46723/figure_1.png>

···

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