From: matthew a. <ma...@ca...> - 2004-02-03 03:04:59
|
Hi again, I'm having more trouble with matplotlib ticks today. I wrote a little demo script that illustrates some of the problems: ... #!/usr/bin/python from matplotlib.matlab import * xx = arange(0.002, 0.0101, 0.001) print xx # an instance of yy = rand(9), so all values are between 0 and 1 yy = [ 5.94692328e-04, 1.62328354e-01, 7.56822907e-01, 2.28180047e-02, 3.23820274e-01, 3.93120900e-01, 6.41332889e-01, 1.22474302e-02, 5.03485402e-01] subplot(211) plot(xx, yy) subplot(212) plot(xx, yy) autoaxis = axis() print autoaxis axis(autoaxis) show() ... * the x axis includes *two* 0.004 and *two* 0.008; this really worried me until I realised it was a cosmetic rounding / significant figures issue, however it's bad enough to be seriously misleading. I think the actual tick values are something like 0.0036 and 0.0044 but are both rounded to 0.004. * the data points lie *between* the x axis ticks, this is a side-effect of the above * the poor choice of tick positions on the y axis -- they should be in round numbers like 0.2, 0.4, etc. The most significant varying figure should be a multiple of 1, 2, or 5. * the tick labels should all have the same number of significant figures, e.g. 0.00, 0.15, 0.30, 0.45, 0.60, ... for the y axis * after manually setting the axis (lower subplot), the last point is not plotted I hope you find this feedback useful. I had a go at fixing it in axis.py, but it's a) fiddly and b) I don't quite understand which part has precendence when the axis changes during a zoom or pan. Getting the ticks right depends on the correct bounds for the axis and the choice of numticks. I noticed you have logic to clean up the bounds (vmin and vmax) but not the ticklocs. Thanks for matplotlib. Cheers, Matthew. |