controlling ticks

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

controlling ticks

Neal Becker
I am plotting with semilogy.  I am getting the tick labels as powers of
10, which is what I want.  However, because the range of data is large, the tick
labels are every 2 powers of 10, [10^-1, 10^-3 ...]

What's the easiest way to change so that the tick labels are for each integer power of 10, [10^-1, 10^-2 ...]?

--
Those who don't understand recursion are doomed to repeat it

_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|

Re: controlling ticks

tcaswell
Lifted from a comment Bruno Beltran made on gitter: https://gitter.im/matplotlib/matplotlib?at=5f888b74631a250ab26f179b

```python
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.ticker

t = np.logspace(0, 4, 10)
fig = plt.figure()
ax = fig.add_subplot()
ax.loglog(t, t**3)

enough_ticks = matplotlib.ticker.LogLocator(numticks=15)
ax.yaxis.set_major_locator(enough_ticks)
```

works, but you have to know how many ticks you want up front.

There are enough knobs on both LogFormatter and LogLocator that this seems like something that should be configurable, but I don't know how off the top of my head (and a very quick look at the source did not have an obvious path).

Tom

On Thu, Oct 15, 2020 at 8:09 AM Neal Becker <[hidden email]> wrote:
I am plotting with semilogy.  I am getting the tick labels as powers of
10, which is what I want.  However, because the range of data is large, the tick
labels are every 2 powers of 10, [10^-1, 10^-3 ...]

What's the easiest way to change so that the tick labels are for each integer power of 10, [10^-1, 10^-2 ...]?

--
Those who don't understand recursion are doomed to repeat it
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users


--
Thomas Caswell
[hidden email]

_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users