SourceForge logo
SourceForge logo
Menu

matplotlib-users

From: Xavier G. <xav...@gm...> - 2008年08月30日 21:13:30
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
From: John H. <jd...@gm...> - 2008年08月31日 03:03:41
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
From: Xavier G. <xav...@gm...> - 2008年08月31日 12:33:52
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
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /