[Matplotlib-users] controlling ticks
Thomas Caswell
tcaswell at gmail.com
Thu Oct 15 13:58:25 EDT 2020
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 <ndbecker2 at gmail.com> 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
> Matplotlib-users at python.org
> https://mail.python.org/mailman/listinfo/matplotlib-users
>
--
Thomas Caswell
tcaswell at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/matplotlib-users/attachments/20201015/e8ade4c7/attachment.html>
More information about the Matplotlib-users
mailing list