Skip to content

SymLogNorm and SymLogScale give inconsistent results.... #16376

Closed

Description

@jklymak

on master....

import matplotlib.pyplot as plt
import numpy as np
import matplotlib.scale as mscale
import matplotlib.colors as mcolors

#scale = mscale.SymmetricalLogScale(ax.xaxis, linthreshx=1.0)
fig, ax =plt.subplots()
ax.set_xscale('symlog', linthreshx=1.0, linscale=1)

ax.plot(np.arange(-100, 100, 0.1), np.arange(-100, 100, 0.1))
ax.set_xlim([-100, 100])
scale = ax.xaxis._scale

norm = mcolors.SymLogNorm(linthresh=1.0, linscale=1, vmin=-100, vmax=100)
xx = scale._transform.transform([-200, -100, -10, -1, -0.5, 0, 0.5, 1, 10, 100, 200])

print((xx - xx[1])/(xx[-2] - xx[1]))
print(norm([-200, -100, -10, -1, -0.5, 0, 0.5, 1, 10, 100, 200]))


fig, ax = plt.subplots()
ax.plot(norm([-200, -100, -10, -1, -0.5, 0, 0.5, 1, 10, 100, 200]), xx, '.')
ax.set_xlabel('Norm')
ax.set_ylabel('Scale')

yields

[-0.0483798207317112 0.0 0.1607142857142857 0.3214285714285714
 0.4107142857142857 0.5 0.5892857142857143 0.6785714285714286
 0.8392857142857143 1.0 1.0483798207317112]   # scale
[-0.05601509  0.          0.1860781   0.3721562   0.4360781   0.5
  0.5639219   0.6278438   0.8139219   1.          1.05601509]  # Norm

I think scale is right, and norm is wrong...

NormIssue2

NormIssue

Activity

  1. jklymak commented on Jan 30, 2020

    @jklymak
    MemberAuthor

    Related to #16280 and #16286

  2. added this to the v3.2.0 milestone on Jan 30, 2020
  3. added
    Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
    on Jan 30, 2020
  4. jklymak commented on Jan 30, 2020

    @jklymak
    MemberAuthor

    Marking release critical because anyone who uses SymLogNorm is possibly plotting corrupted data?

  5. jklymak commented on Jan 31, 2020

    @jklymak
    MemberAuthor

    I feel this issue is a pretty big emergency. Anyone using this norm for published work is publishing incorrect data. The fact that it’s been broken forever is pretty brutal because who knows how many papers have this error. (Hopefully few, because it’s a pretty unconventional norm).

  6. jklymak commented on Feb 1, 2020

    @jklymak
    MemberAuthor

    See #16375 (comment) for @anntzer possible path to fixing the problem.

  7. jklymak commented on Feb 2, 2020

    @jklymak
    MemberAuthor

    OK, the issue is that SymLogNorm is hard coded with base np.e, whereas scale takes a variable base, but defaults to 10. I guess its arguable what the base should be by default. ping @dstansby? Did you know the norm was not base-10, but rather base-e? Should we just keep it that way for historic reasons? I don't think most people want or expect base-e...

  8. jklymak commented on Feb 2, 2020

    @jklymak
    MemberAuthor

    Like the doc string even says "decades", which I don't think it correct for base-e.

  9. dstansby commented on Feb 2, 2020

    @dstansby
    Member

    I always read it as base 10, because it says 'decades'.

  10. dstansby commented on Feb 2, 2020

    @dstansby
    Member

    PR open, thanks again for tracking this down and opening the issue

  11. modified the milestones: v3.2.0, v3.3.0 on Feb 16, 2020
  12. modified the milestones: v3.3.0, v3.4.0 on May 23, 2020
  13. dstansby commented on Jun 26, 2020

    @dstansby
    Member

    Just a heads up that I'm going to try and tackle this again. #16391 as it stands has tests with correct and hand-calculable values, that fail for norm (without the changes in that PR) and scale. Hopefully we can get #16457 in for LogNorm, which will then allow me to derive SymLogNorm from SymLogScale and fix both at the same time.

  14. jklymak commented on Jan 5, 2021

    @jklymak
    MemberAuthor

    This was closed by #16457 FAICT...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.topic: color/color & colormaps

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions