473,395 Members | 1,516 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

[matplotlib] Overlapping axis text

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.
Sep 6 '08 #1
2 5088
Err...made a mistake there.

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

That doesn't change my question though.

Thanks
Sep 6 '08 #2

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.

Nov 10 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: John Hunter | last post by:
matplotlib is a 2D plotting package for python with a matlab compatible syntax and output tested under linux and windows platforms. matplotlib-0.30 is available for download at...
5
by: Enigma Curry | last post by:
I'm playing around with matplotlib for the first time. I'm trying to make a very simple histogram of values 1-6 and how many times they occur in a sequence. However, after about an hour of...
2
by: Caleb Hattingh | last post by:
Hi I tried several Google searches to no avail. I read through pretty much most of the online docs at the matplotlib sourceforge site, but didn't find what I was looking for. I went through...
0
by: dhn | last post by:
I am trying to automate the generation of scatterplots in matplotlib. The problem of where to put the labels is known as 'point-feature labeling' (a main application is in cartography, where cities...
2
by: Grant Edwards | last post by:
I downloaded examples/contour_demo.py, and it doesn't run. I've searched both the user guide and the Wiki for "contour" and got zero hits. ...
0
by: Soren | last post by:
Hi, I'm trying to create a small GUI program where I can do plots using Matplotlib. I've been trying to borrow code from the examples at the matplotlib website, but I can't get it to work. I...
4
by: Bill Jackson | last post by:
Hi, I'm having some trouble plotting with the following matplotlibrc: text.usetex : True I tried clearing the cache files under ~/.matplotlib, but this did not help the problem. I'd post...
0
by: Dick Crepeau | last post by:
I would like to control the y axis of a plot. The following code does exactly what I want it to! On my linux computer it sets the y axis limits to 18.0 minimum, 58.0 maximum, plots some points on...
1
by: Eric Holbrook | last post by:
I'm using matplotlib to generate (and save) plots of bandwidth data from simulation logs. Since the simulations are of varying lengths, i need a way to scale the axes so that every 100,000 points...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.