|
From: Friedrich R. <fri...@gm...> - 2010-10-19 19:50:24
|
2010/10/19 Jonathan Slavin <js...@cf...>:
> I think that'd be fine -- i.e. the option of \cdot or \times (though in
> the gmane preview the dot looks a bit low). In the mean time, I came up
> with the method below that worked for my purpose.
Okay thx
> import matplotlib.pyplot as plt
> import numpy as np
> from matplotlib.ticker import FuncFormatter
>
> def scinot(x,pos=None):
> if x == 0:
> s = '0'
> else:
> xp = int(np.floor(np.log10(np.abs(x))))
> mn = x/10.**xp
> # Here we truncate to 2 significant digits -- may not be enough
> # in all cases
> s = '$'+str('%.1f'%mn) +'\\times 10^{'+str(xp)+'}$'
> return s
>
> x = np.linspace(0.,2.,10)*1.E18
> y = 2.*(x/1.E18) - 1.
> fig = plt.figure()
> ax = fig.add_subplot(111)
> ax.plot(x,y)
> ax.xaxis.set_major_formatter(FucFormatter(scinot))
typo for the records although abvious: FuncFormatter
> plt.show()
Okay I can do the tedious work of changing my code ASAP but with low
priority ...
Friedrich
|