From: jfortiv <jf...@gm...> - 2011-04-18 02:52:45
|
Hello, I'm trying to create a bar chart that looks something like a gannt chart... See the simple example here: http://www.promana.net/making-use-of-gantt-charts/ I'm trying to utilize barh() and fmt_xdata to accomplish this with the following: #~~~~~~~~~~~~~~~~~~~~~~~ date1 = datetime.datetime( 2000, 3, 2) date2 = datetime.datetime( 2000, 3, 6) delta = datetime.timedelta(hours=6) dates = mdates.drange(date1, date2, delta) val = mdates.drange(date1,date2,delta) # the bar lengths pos = range(len(val)) # the bar centers on the y axis height=0.5 # the bar height left=mdates.drange(date1,date2,delta) # the bar starting position fig = plt.figure() ax = fig.add_subplot(111) ax.barh(pos,val,height=height,left=left,align='center',alpha=0.3) ax.fmt_xdata = mdates.DateFormatter('%Y-%m-%d %H:%M:%S') #~~~~~~~~~~~~~~~~~~~~~~~ Even with ax.fmt_xdata, I'm simply getting numbers on the x-axis instead of dates. Can anyone offer some pointers? Thanks, James -- View this message in context: http://old.nabble.com/Date-format-the-x-axis-of-a-barh%28%29-plot--tp31420395p31420395.html Sent from the matplotlib - users mailing list archive at Nabble.com. |
From: Sebastian B. <seb...@si...> - 2011-04-18 14:27:25
|
Hello, don't know the foo behind it, but using ax.xaxis.set_major_formatter(mdates.DateFormatter('%Y-%m-%d %H:%M:%S')) works. Regards, Sebastian On Sun, 2011-04-17 at 19:52 -0700, jfortiv wrote: > Hello, > > I'm trying to create a bar chart that looks something like a gannt chart... > > See the simple example here: > > http://www.promana.net/making-use-of-gantt-charts/ > > I'm trying to utilize barh() and fmt_xdata to accomplish this with the > following: > > #~~~~~~~~~~~~~~~~~~~~~~~ > > date1 = datetime.datetime( 2000, 3, 2) > date2 = datetime.datetime( 2000, 3, 6) > delta = datetime.timedelta(hours=6) > dates = mdates.drange(date1, date2, delta) > > val = mdates.drange(date1,date2,delta) # the bar lengths > pos = range(len(val)) # the bar centers on the y axis > height=0.5 # the bar height > left=mdates.drange(date1,date2,delta) # the bar starting position > > fig = plt.figure() > ax = fig.add_subplot(111) > ax.barh(pos,val,height=height,left=left,align='center',alpha=0.3) > ax.fmt_xdata = mdates.DateFormatter('%Y-%m-%d %H:%M:%S') > > #~~~~~~~~~~~~~~~~~~~~~~~ > > > Even with ax.fmt_xdata, I'm simply getting numbers on the x-axis instead of > dates. Can anyone offer some pointers? > > Thanks, > James |
From: jfortiv <jf...@gm...> - 2011-04-23 08:48:24
|
Hi, This actually did not work for me. Can you show me the full code that you used to successfully produce the time-format x-axis labels? Thanks, James Sebastian Berg wrote: > > Hello, > > don't know the foo behind it, but using > ax.xaxis.set_major_formatter(mdates.DateFormatter('%Y-%m-%d %H:%M:%S')) > works. > > Regards, > > Sebastian > > On Sun, 2011-04-17 at 19:52 -0700, jfortiv wrote: > >> Hello, >> >> I'm trying to create a bar chart that looks something like a gannt >> chart... >> >> See the simple example here: >> >> http://www.promana.net/making-use-of-gantt-charts/ >> >> I'm trying to utilize barh() and fmt_xdata to accomplish this with the >> following: >> >> #~~~~~~~~~~~~~~~~~~~~~~~ >> >> date1 = datetime.datetime( 2000, 3, 2) >> date2 = datetime.datetime( 2000, 3, 6) >> delta = datetime.timedelta(hours=6) >> dates = mdates.drange(date1, date2, delta) >> >> val = mdates.drange(date1,date2,delta) # the bar lengths >> pos = range(len(val)) # the bar centers on the y axis >> height=0.5 # the bar height >> left=mdates.drange(date1,date2,delta) # the bar starting position >> >> fig = plt.figure() >> ax = fig.add_subplot(111) >> ax.barh(pos,val,height=height,left=left,align='center',alpha=0.3) >> ax.fmt_xdata = mdates.DateFormatter('%Y-%m-%d %H:%M:%S') >> >> #~~~~~~~~~~~~~~~~~~~~~~~ >> >> >> Even with ax.fmt_xdata, I'm simply getting numbers on the x-axis instead >> of >> dates. Can anyone offer some pointers? >> >> Thanks, >> James > > > > ------------------------------------------------------------------------------ > Benefiting from Server Virtualization: Beyond Initial Workload > Consolidation -- Increasing the use of server virtualization is a top > priority.Virtualization can reduce costs, simplify management, and improve > application availability and disaster protection. Learn more about > boosting > the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > -- View this message in context: http://old.nabble.com/Date-format-the-x-axis-of-a-barh%28%29-plot--tp31420395p31460691.html Sent from the matplotlib - users mailing list archive at Nabble.com. |
From: Goyo <goy...@gm...> - 2011-04-23 12:42:13
Attachments:
sample.py
sample.png
|
2011/4/23 jfortiv <jf...@gm...>: > > Hi, > > This actually did not work for me. Can you show me the full code that you > used to successfully produce the time-format x-axis labels? See attached files. Goyo |
From: jfortiv <jf...@gm...> - 2011-04-28 04:32:08
|
This worked. Thank you very much! For some reason I had commented out ax.fmt_xdata = ... This is exactly what I needed. James Goyo wrote: > > 2011/4/23 jfortiv <jf...@gm...>: >> >> Hi, >> >> This actually did not work for me. Can you show me the full code that >> you >> used to successfully produce the time-format x-axis labels? > > See attached files. > > Goyo > > > > ------------------------------------------------------------------------------ > Fulfilling the Lean Software Promise > Lean software platforms are now widely adopted and the benefits have been > demonstrated beyond question. Learn why your peers are replacing JEE > containers with lightweight application servers - and what you can gain > from the move. http://p.sf.net/sfu/vmware-sfemails > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > -- View this message in context: http://old.nabble.com/Date-format-the-x-axis-of-a-barh%28%29-plot--tp31420395p31493421.html Sent from the matplotlib - users mailing list archive at Nabble.com. |