Repository navigation
Description
Bug report
Bug summary
SymLog scale is exactly what I need to display various reinforcement learning related metrics as they can be both positive and negative, interesting mainly in the -10 to 10 range, and frequently explode to very large values only to come back "to sanity" later.
Unfortunately, if things go well and metrics don't go insane, current SymLog graphs have too few ticks and is not possible to understand what am I looking at. Here is a synthetic example that illustrates the issue quite well:
Code for reproduction
import matplotlib.pyplot as plt
import numpy as np
st = np.random.standard_cauchy(size=25)
en = np.random.standard_cauchy(size=25)
fig, axen = plt.subplots(5, 5, figsize=(20, 20))
fig.tight_layout()
for ax, s, e in zip(np.ravel(axen), st, en):
ax.plot(np.linspace(s, e, 5))
ax.set_yscale('symlog')Actual outcome
Expected outcome
It would be awesome to get more ticks and nicer labels!
Matplotlib version
matplotlib 3.1.1
I think the versions of all the remaining stuff are irrelevant, as this is an issue in the SymmetricalLogLocator class, which is built on an assumption that does not hold in my case:
# b) has a tick at 0 and only 0 (we assume t is a small
# number, and the linear segment is just an implementation
# detail and not interesting.)

Activity
psarka commentedon May 13, 2020
I imagine this will be quite tricky to fix, so in case someone is in urgent need of extra ticks, here is a quick and dirty code that works quite well for me:
And then when you do the plot, add this:
This solution is still broken in some cases, hardcoded to base 10 and threshold 1 (doesn't it make more sense than 2 as a default?), but works better than default:
tacaswell commentedon May 14, 2020
This behaves slightly better (I think? it is hard to tell with the randomness) on master.
There was recently a bunch of work with the log formatters and locators to make sure we always had a reasonable number of ticks on the screen, the fix here would likely be to see if any of those code patterns / logic can be adapted.
tacaswell commentedon May 14, 2020
I labeled this a "good first issue" because the changes required are likely to be isolated to the locator / formatter for symlog, but medium difficulty as it will involve reaching a consensus on what the "right" behavior is.
Jaroza727 commentedon Nov 28, 2020
Doesn't look like anyone is working on this, so I'd like to take this up.
Schmutsi commentedon Nov 30, 2020
Hello,
In fact, we are working on this issue for few weeks. And we assume having fixed the issue. Here is the code that we have changed (in the class SymetricalLogLocator() - function tick_values() ) illustrated by an example with 16 graphs. We just had a condition at the end of the function.
Thus, we are going to do a pull request.
AxelMKlein commentedon Sep 30, 2021
Hello,
May I ask when this will be available?
Sorry for my lack of knowledge, can I make this somehow work locally in my project? If so, how?
stanleyjs commentedon Nov 9, 2021
@AxelMKlein This seems to be dead. Maybe @QuLogic has it in mind for v3.6. In the meantime, I think you can take @Schmutsi 's code and set your ticks using it. Something like
ax.set_yticks(tick_values(vmin,vmax))appears to be the trick to set the yticks. Or follow @psarka 's answer.saitejaponnam12 commentedon Mar 25, 2026
Hi, I'd like to work on this issue.
I’ll start by reproducing the behavior with a minimal example and then
look into how ticks are generated for the SymLog scale.
Please let me know if this is still available.
saitejaponnam12 commentedon Mar 25, 2026
#31381 is another attempt at addressing #17402.
I noticed #27310 previously explored improving symlog ticks, but the issue
remains open. This patch proposes a smaller, focused adjustment to improve
tick density in the linear region.