Hello All,
I am having lots of very frustrating little problems with Matplotlib.
1. Here is an example of one problem: the x-axis looks awful even though I
coded a tick locator and tick formatter special:
http://www.nabble.com/file/p22989017/inE.png
I think I know what caused this, too. While plotting, Python gave the
error/warning "DeprecationWarning: integer argument expected, got float
tzinfo=rr._ tzinfo". With many very similar data sets, it doesn't give that
error and draws nice tick marks like this:
http://www.nabble.com/file/p22989017/31%2B2009.png
Is the error caused by the fact that the data doesn't fill the whole X-axis?
That would be an unfortunate reason to fail, especially considering the
second problem...
2. Here is another problem: GTK on my MacBook always successfully changes
the X-axis limits when I say plt.xlim(number1, number2). Using the Agg
backend on an Ubuntu server (which doesn't have GTK because it is headless),
xlim NEVER works. Ubuntu with Agg draws a graph fine, but it uses whatever
limits it would have used default. Example from Ubuntu with Agg:
http://www.nabble.com/file/p22989017/Matplotlib%2Bgraph%2B-%2BExemplifies%2Bdate%2Bformatting%2Band%2Bxlim%2Bbugs.png
Example from my MacBook with GTK:
http://www.nabble.com/file/p22989017/22%2B2009.png
3. The final problem is also demonstrated by the two example images in
problem #2 above: Agg completely ignores my tick formatter, and perhaps also
my tick locator. Why?
Here is all of the relevant Matplotlib code I am using:
plt.clf()
ax = plt.subplot(111)
if dateMin:
plt.xlim(xmin=dateMin, xmax=dateMax)
plt.plot(yDates, xIntensity)
xmin, xmax = plt.xlim()
xrange = num2date(xmax)-num2date(xmin)
if xrange < datetime.timedelta(hours=24):
widthInUnits = divideDelta(xrange, datetime.timedelta(hours=1))
stepRaw = widthInUnits/5. #The denominator here is the maximum number of
ticks on the x axis. So putting 5 in the denominator, as I have done here,
means there will be up to 5 tick marks.
step = floor(stepRaw+1)
majorFormatter = DateFormatter('%I:%M %p')
majorLocator = HourLocator(interval=step)
elif xrange < datetime.timedelta(days=5):
widthInUnits = divideDelta(xrange, datetime.timedelta(hours=12))
stepRaw = widthInUnits/7.
step = floor(stepRaw+1)
majorFormatter = DateFormatter('%m/%d\n%I%p')
majorLocator = HourLocator(interval=step*12)
elif xrange < datetime.timedelta(days=300):
widthInUnits = divideDelta(xrange, datetime.timedelta(days=1))
stepRaw = widthInUnits/8.
step = floor(stepRaw+1)
majorFormatter = DateFormatter('%m/%d')
majorLocator = DayLocator(interval=step)
else:
widthInUnits = divideDelta(xrange, datetime.timedelta(days=30))
stepRaw = widthInUnits/7.
step = floor(stepRaw+1)
majorFormatter = DateFormatter('%b\n%Y')
majorLocator = MonthLocator(interval=int(step))
ax.xaxis.set_major_locator(majorLocator)
ax.xaxis.set_major_formatter(majorFormatter)
if dateMark:
for mark in dateMark:
l = plt.axvline(x=mark, color='r')
plt.savefig(str(filePath+'/'+fileNameExt))
Thank you, I hope somebody can help.
···
--
View this message in context: http://www.nabble.com/Lots-of-little-problems-with-appearance-(Agg-vs.-GTK%2C-xlim%2C-tick-locators)-tp22989017p22989017.html
Sent from the matplotlib - users mailing list archive at Nabble.com.