Repository navigation
Description
Hi, @mdboom.
Can you roughly explain the meaning of _linscale_adj in SymmetricalLogTransform which was introduced via d8bf0fed4d62324489ffe1d21d114c87ae9ca6a4?
class SymmetricalLogTransform(Transform):
input_dims = 1
output_dims = 1
is_separable = True
has_inverse = True
def __init__(self, base, linthresh, linscale):
Transform.__init__(self)
self.base = base
self.linthresh = linthresh
self.linscale = linscale
self._linscale_adj = (linscale / (1.0 - self.base ** -1))
self._log_base = np.log(base)
I am quite puzzled by it.
According to the documentation about linscalex / linscaley, its value is the number of decades to use for each half of the linear range. For example, when linscale == 1.0 (the default), the space used for the positive and negative halves of the linear range will be equal to one decade in the logarithmic range.
As I understand it, it means that when the base is 10 and the linthresh equals to 1, the length of the interval between 0 and 1 should equal to the interval between 1(10^0) and 10(10^1). And this feature seems to be very useful that user can adjust the relative ratio between linear range and logarithmic range.
However, since the _linscale_adj amplifies the original linscale by 1/(1-1/base), the actual place for the linear range will be 1.11x compared to logarithmic range per decade.
For example,
import numpy as np
import matplotlib.pyplot as plt
x = np.array([0, 1, 5, 10, 100, 1000])
y = np.array([0] * 6)
plt.scatter(x, y)
plt.xscale('symlog', linthreshx=10, basex=10, linscalex=1)
plt.grid(True)
plt.show()
If the base is set to 2, the linear range will be 2x than logarithmic range per decade and this issue may be more considerable:
import numpy as np
import matplotlib.pyplot as plt
x = np.array([0, 0.5, 1, 2, 4, 8, 16])
y = np.array([0] * 7)
plt.scatter(x, y)
plt.xscale('symlog', linthreshx=2, basex=2, linscalex=1)
plt.grid(True)
plt.show()
Since _linscale_adj is relatively independent and is only used to be a coefficient of transformation for symlog, it seems not to be a bug. So, what is the meaning of the scaling of _linscale_adj which related to its base?
Well, as a user, the figures showed above is very weird and I used to set the linscale manually to 0.9 (base=10) to make each tick interval to be equal.
Thanks.


Activity
desert0616 commentedon Sep 24, 2016
is any comment for this issue?
tacaswell commentedon Sep 24, 2016
@phobson You think a lot about non-linear scales, do you have any insight into this?
phobson commentedon Sep 27, 2016
I'm still catching up on paid gig stuff after my vacation. But I'll shoot to give this a good look later in the week.
jgehrcke commentedon Jun 26, 2019
I think this should get more attention. I cannot submit a bug report right now, I don't have enough clarity, but I face a quite similar issue with
symlog, where the tick intervals are not equidistant.phobson commentedon Jun 26, 2019
@jgehrcke could you add a small example that illustrates what you're describing to this issue?
jgehrcke commentedon Jun 26, 2019
Thanks for asking :)
I would expect the distance between the
10^0tick and the10^1tick to be equal to the distance between the10^1and the10^2tick (equidistant major tick marks are the goal by default, right?).However, the distance between the
10^0tick and the10^1tick is larger. That is unusual.desert0616 commentedon Jun 26, 2019
wow... amazing, this thread is still alive after 3 years...
jklymak commentedon Jun 26, 2019
linthreshxandlinthreshydefault to 2. Tryplt.yscale('symlog', linthreshy=1)phobson commentedon Jun 26, 2019
This is fascinating
jklymak commentedon Jun 26, 2019
But that's correct...
phobson commentedon Jun 26, 2019
Oh yeah, I had brain farted on 10^0 = 1
phobson commentedon Jun 26, 2019
so the gap between 1 and 0 changing makes sense and same for the game between 1 and 10
jgehrcke commentedon Jun 26, 2019
Dang! I assumed it's 1. Not documented here: https://matplotlib.org/3.1.0/api/scale_api.html#matplotlib.scale.SymmetricalLogScale
But interestingly the "Defaults to 2" has very recently been added here: 2679354#diff-9e3c26547d61ec9447f5420ec32f08f4R549 -- so I suppose with the next release the documentation will be clearer.
Thanks! So, "my issue" here is resolved. Lovely.
jklymak commentedon Jun 26, 2019
@jgehrcke good point. that should be fixed. Any appetite for making a PR to do that?
timhoffm commentedon Jun 29, 2019
@jklymak What exactly needs fixing? The documentation is already fixed by 2679354#diff-9e3c26547d61ec9447f5420ec32f08f4R549:
https://matplotlib.org/devdocs/api/scale_api.html#matplotlib.scale.SymmetricalLogScale
gregcolyer commentedon Jul 19, 2019
Even in @phobson's linthreshy=1 plot above, there is still a different gap between 0 and 1 vs. 1 and 10, presumably due to the (1-1/b) factor mentioned originally by @desert0616 at the top. Cf. issue #10369, where I suggested what to change in the code and/or documentation to address this: for the examples there I also set linthreshy=1, so I'm not sure if I thought about other values (or if that is independent).
YannDubs commentedon Mar 6, 2020
putting together what @gregcolyer and @desert0616 said (and code in #10369). There are 2 current workarounds depending on what you want (equidistant or smooth):
QuLogic commentedon Mar 11, 2020
@YannDubs That seems like a pretty good example (or maybe tutorial), would you like to make a PR adding it? It would need some amount of prose added to explain what it does. It could supplement
examples/scales/symlog_demo.py.github-actions commentedon Mar 28, 2023
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!