Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > [matplotlib] Overlapping axis text

Reply
Thread Tools

[matplotlib] Overlapping axis text

 
 
Durand
Guest
Posts: n/a
 
      09-06-2008
I got a really annoying problem with datetime graphs. The problem is
that with a long range time graph, the text on the x axis keeps
overlapping like here: http://durand.zephyrhosting.net/tremcs/graph_all.png

Would there be any way to fix this? I was thinking of rotating the
text so that there was enough space for each one but the best solution
would be to only display text with the right scale. IE, with a 7 day
graph, each day would have text, with a year long graph, each month
would be displayed, etc...

This is the code I use at the moment but its pretty messy:

import dateutil,pylab
from matplotlib.dates import MonthLocator, WeekdayLocator

fig = pylab.figure()
ax = fig.add_subplot(111)
days = MonthLocator() # every monday
months = MonthLocator() # every month
ax.xaxis.set_major_locator(months)
ax.xaxis.set_minor_locator(days)

pylab.plot_date(pylab.date2num(dates), allkills, '.-', color='blue')
pylab.plot_date(pylab.date2num(dates), alldeaths, '.-',
color='red')
pylab.plot_date(pylab.date2num(dates), kills, '.-',
color='darkgreen')
pylab.plot_date(pylab.date2num(dates), deaths, '.-',
color='orange')
if legend == 1:
pylab.legend(("Total Kills","Total Deaths", "Single
Session Kills", "Single Session Deaths"), 'lower left')
pylab.xlabel('Date')
pylab.ylabel('Stats')
ax2 = pylab.twinx()
pylab.plot_date(pylab.date2num(dates), allratio, '.-',
color='purple')
pylab.plot_date(pylab.date2num(dates), ratio, '.-',
color='yellow')
pylab.ylabel('Ratio')
ax2.yaxis.tick_right()
pylab.show()
Please excuse the extra tabbing, it's part of an if statement.
 
Reply With Quote
 
 
 
 
Durand
Guest
Posts: n/a
 
      09-06-2008
Err...made a mistake there.

days = WeekdayLocator() # every monday
months = MonthLocator() # every month

That doesn't change my question though.

Thanks
 
Reply With Quote
 
 
 
 
McBuell
Guest
Posts: n/a
 
      11-10-2008

try this:

fig.autofmt_xdate()

should help a lot =)

Cheers
--
View this message in context: http://www.nabble.com/-matplotlib--O...p20430433.html
Sent from the Python - python-list mailing list archive at Nabble.com.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Text overlapping other text when I resize my page kk.simhadri@gmail.com HTML 2 04-20-2007 05:22 PM
Calling a Web Service using Axis, from within an Axis Web Service running under Tomcat hocho888 Java 1 04-29-2005 08:26 PM
AXIS jars org.apache.axis.wsi.* and org.apache.axis.transport.jms.* unkwb@web.de Java 0 02-23-2005 04:02 PM
Axis 1.1 don't delete attachments in the axis attachment cache Stefan Java 0 05-06-2004 08:00 PM
axis.jar does not contain org.apache.axis.client.ServiceClient? Joey Vendetta Java 0 04-01-2004 05:51 PM



Advertisments