Hi, I'm using the TkAgg backend. It is nice and fine except one issue: Here is a trivial testcase: import pylab import numpy M=numpy.zeros((2000,2000)) pylab.imshow(M) The cursor position is displayed this way: x=1.23e03 y=1.72e03 (in right corner of the window) It should be formated as intergers and not as floats. It is not only cosmetics because with 1.23e03, we are missing the last digit (it matters in my usecase and anyhow it is q bit stupid). The fix should be trivial but I have to find the line of interest... Xavier
On Sat, Aug 30, 2008 at 4:13 PM, Xavier Gnata <xav...@gm...> wrote: > Hi, > > I'm using the TkAgg backend. It is nice and fine except one issue: > > Here is a trivial testcase: > > import pylab > import numpy > > M=numpy.zeros((2000,2000)) > pylab.imshow(M) > > The cursor position is displayed this way: x=1.23e03 y=1.72e03 (in right > corner of the window) > It should be formated as intergers and not as floats. > > It is not only cosmetics because with 1.23e03, we are missing the last > digit (it matters in my usecase and anyhow it is q bit stupid). > > The fix should be trivial but I have to find the line of interest... The x and y toolbar coordinate formatting are controlled by a pair of functions, fmt_xdata and fmt_ydata. You can set them to be anything you like, eg for integer formatting: def format_int(x): return '%d'%int(x) ax.fmt_xdata = format_int JDH
John Hunter wrote: > On Sat, Aug 30, 2008 at 4:13 PM, Xavier Gnata <xav...@gm...> wrote: > >> Hi, >> >> I'm using the TkAgg backend. It is nice and fine except one issue: >> >> Here is a trivial testcase: >> >> import pylab >> import numpy >> >> M=numpy.zeros((2000,2000)) >> pylab.imshow(M) >> >> The cursor position is displayed this way: x=1.23e03 y=1.72e03 (in right >> corner of the window) >> It should be formated as intergers and not as floats. >> >> It is not only cosmetics because with 1.23e03, we are missing the last >> digit (it matters in my usecase and anyhow it is q bit stupid). >> >> The fix should be trivial but I have to find the line of interest... >> > > The x and y toolbar coordinate formatting are controlled by a pair of > functions, fmt_xdata and fmt_ydata. You can set them to be anything > you like, eg for integer formatting: > > def format_int(pylab.imshow(M)x): > return '%d'%int(x) > > ax.fmt_xdata = format_int > > > JDH > Ok thanks it does the job. However, I think it should really be done by default. self.xaxis.major.formatter.set_scientific(sb) is not the best way to display pixel numbers (IMHO). Xavier