I am currently trying to improve the labelling of a contour plot. As contours I'm only using negative powers of ten, so I hope to have a simple LaTeX label of the form, say, 10^{-23}. My starting point was one of the examples at the help page for contour_plot (here was the link to the sage documentation). After various failed attempts with log(x, 10), I found in the question "Integer types and log()" (that would be question id(?) 28679/integer-types-and-log) an example using valuation(x,10). However, the results seem odd. Below the slightly simplified thing I try to plot.

```
var('x y')
rp = 6.77048070412999e-10*(x + sqrt(x^2-y^2*x^2))
sigma0 = 1.44008750449331e-18*(3*x + sqrt(9*x^2 - 8*y^2*x^2))^4/(8*(3*x^2 - 2*y^2*x^2 + x*sqrt(9*x^2 - 8*y^2*x^2)))
f(x,y) = (1.12469227142351e-70*y*x^2/(rp)^6*exp(-(rp)^2/(sqrt(y)*x*0.169262017603250))-1.65389403372211e-162*(sqrt(x^2-y*x^2))^3*sigma0*(x-2*sqrt(x^2-y*x^2))/(rp)^10)
contour_plot(f(x,y), (x,0,100), (y,0,1), contours=[0,1e-25,1e-24,1e-23,1e-22,1e-21,1e-20,1e-19],aspect_ratio='automatic',labels=True, label_fmt=lambda x: r'''$10^{-%s}$'''%(valuation(1/x,10)), fill=False)
```

If I do this, I get 10^{-0} for several contours.

So, I checked, what valuation does to the numbers:

```
print(valuation(1/(1e-19),10))
print(valuation(1/(1e-20),10))
print(valuation(1/(1e-21),10))
print(valuation(1/(1e-22),10))
print(valuation(1/(1e-23),10))
```

yielding

```
19
20
0
22
0
```

If I'm using something like

```
label_fmt=lambda x: r'''$10^{-%s}$'''%(log(1/x,10))
```

instead, I get only the message "Graphics object consisting of 1 graphics primitive", and

```
label_fmt=lambda x: r'''$10^{-%s}$'''%(log(Integer(1/x),10))
```

yields another plot with odd labels - which have the odd behaviour at the same exponents as the example with "valuation", but I don't know why.

I'm currently doing this mostly in a jupyter notebook on Windows 10 with Sage 9.1.

Am I misunderstanding the use of "valuation" or log(x,10) in this case? Did I run into a bug? How can I get the exponents I'm after?