Skip to content

imshow with log/symlog scales fails to produce figures without raising an Exception #3931

Closed

Description

@eyurtsev

I don't know if it makes sense to use imshow with non-linear scales. However, it would be nice if imshow at least raised an Exception in the cases where it's supposed to fail.

matplotlib v 1.4.2

%pylab inline

Z = randn(10000).reshape(100, -1)

# Works
figure()
imshow(Z)

# Produces no figure if x/y limits are not specified
# Does NOT raise an exception!
figure()
imshow(Z)
xscale('log')
yscale('log')

# Works
figure()
imshow(Z)
xscale('log')
yscale('log')
xlim(1, 20)
ylim(1, 20)

# Produces no figure in symlog scale
# Does NOT raise an exception!
figure()
imshow(Z)
xscale('symlog')
yscale('symlog')

# Produces no figure in symlog scale
# Does NOT raise an exception!
figure()
imshow(Z)
xscale('symlog', linthreshx=10**-3)
yscale('symlog', linthreshy=10**-3)
xlim(0, 20)
ylim(0, 20)

Activity

  1. added this to the milestone on Feb 19, 2015
  2. added
    API: consistencyConsistency of the matplotlib API, including naming, behavior, defaults, …
    on Feb 19, 2015
  3. tacaswell commented on Feb 19, 2015

    @tacaswell
    Member

    When I run this I get all sorts of warnings:

    /home/tcaswell/.virtualenvs/dd_py3/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-linux-x86_64.egg/matplotlib/image.py:357: UserWarning: Images are not supported on non-linear axes.
      warnings.warn("Images are not supported on non-linear axes.")
    /home/tcaswell/.virtualenvs/dd_py3/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-linux-x86_64.egg/matplotlib/transforms.py:2557: RuntimeWarning: divide by zero encountered in double_scalars
      x_scale = 1.0 / inw
    /home/tcaswell/.virtualenvs/dd_py3/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-linux-x86_64.egg/matplotlib/transforms.py:2558: RuntimeWarning: divide by zero encountered in double_scalars
      y_scale = 1.0 / inh
    /home/tcaswell/.virtualenvs/dd_py3/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-linux-x86_64.egg/matplotlib/axis.py:1001: UserWarning: Unable to find pixel distance along axis for                    interval padding of ticks; assuming no interval padding                    needed.
      needed.")
    /home/tcaswell/.virtualenvs/dd_py3/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-linux-x86_64.egg/matplotlib/axis.py:1011: UserWarning: Unable to find pixel distance along axis for                    interval padding of ticks; assuming no interval padding                    needed.
      needed.")
    Traceback (most recent call last):
      File "/home/tcaswell/.virtualenvs/dd_py3/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-linux-x86_64.egg/matplotlib/backends/backend_qt5.py", line 430, in idle_draw
        self.draw()
      File "/home/tcaswell/.virtualenvs/dd_py3/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-linux-x86_64.egg/matplotlib/backends/backend_qt5agg.py", line 143, in draw
        FigureCanvasAgg.draw(self)
      File "/home/tcaswell/.virtualenvs/dd_py3/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-linux-x86_64.egg/matplotlib/backends/backend_agg.py", line 475, in draw
        self.figure.draw(self.renderer)
      File "/home/tcaswell/.virtualenvs/dd_py3/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-linux-x86_64.egg/matplotlib/artist.py", line 60, in draw_wrapper
        draw(artist, renderer, *args, **kwargs)
      File "/home/tcaswell/.virtualenvs/dd_py3/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-linux-x86_64.egg/matplotlib/figure.py", line 1094, in draw
        func(*args)
      File "/home/tcaswell/.virtualenvs/dd_py3/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-linux-x86_64.egg/matplotlib/artist.py", line 60, in draw_wrapper
        draw(artist, renderer, *args, **kwargs)
      File "/home/tcaswell/.virtualenvs/dd_py3/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-linux-x86_64.egg/matplotlib/axes/_base.py", line 2006, in draw
        self.apply_aspect()
      File "/home/tcaswell/.virtualenvs/dd_py3/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-linux-x86_64.egg/matplotlib/axes/_base.py", line 1193, in apply_aspect
        if aspect_scale_mode == "log":
    UnboundLocalError: local variable 'aspect_scale_mode' referenced before assignment
    
    If you suspect this is an IPython bug, please report it at:
        https://github.com/ipython/ipython/issues
    or send an email to the mailing list at ipython-dev@scipy.org
    
    You can print a more detailed traceback right now with "%tb", or use "%debug"
    to interactively debug it.
    
    Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
        %config Application.verbose_crash=True
    
    Traceback (most recent call last):
      File "/home/tcaswell/.virtualenvs/dd_py3/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-linux-x86_64.egg/matplotlib/backends/backend_qt5.py", line 430, in idle_draw
        self.draw()
      File "/home/tcaswell/.virtualenvs/dd_py3/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-linux-x86_64.egg/matplotlib/backends/backend_qt5agg.py", line 143, in draw
        FigureCanvasAgg.draw(self)
      File "/home/tcaswell/.virtualenvs/dd_py3/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-linux-x86_64.egg/matplotlib/backends/backend_agg.py", line 475, in draw
        self.figure.draw(self.renderer)
      File "/home/tcaswell/.virtualenvs/dd_py3/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-linux-x86_64.egg/matplotlib/artist.py", line 60, in draw_wrapper
        draw(artist, renderer, *args, **kwargs)
      File "/home/tcaswell/.virtualenvs/dd_py3/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-linux-x86_64.egg/matplotlib/figure.py", line 1094, in draw
        func(*args)
      File "/home/tcaswell/.virtualenvs/dd_py3/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-linux-x86_64.egg/matplotlib/artist.py", line 60, in draw_wrapper
        draw(artist, renderer, *args, **kwargs)
      File "/home/tcaswell/.virtualenvs/dd_py3/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-linux-x86_64.egg/matplotlib/axes/_base.py", line 2006, in draw
        self.apply_aspect()
      File "/home/tcaswell/.virtualenvs/dd_py3/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-linux-x86_64.egg/matplotlib/axes/_base.py", line 1193, in apply_aspect
        if aspect_scale_mode == "log":
    UnboundLocalError: local variable 'aspect_scale_mode' referenced before assignment
    
    If you suspect this is an IPython bug, please report it at:
        https://github.com/ipython/ipython/issues
    or send an email to the mailing list at ipython-dev@scipy.org
    
    You can print a more detailed traceback right now with "%tb", or use "%debug"
    to interactively debug it.
    
    Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
        %config Application.verbose_crash=True
    
    Traceback (most recent call last):
      File "/home/tcaswell/.virtualenvs/dd_py3/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-linux-x86_64.egg/matplotlib/backends/backend_qt5.py", line 341, in resizeEvent
        self.draw()
      File "/home/tcaswell/.virtualenvs/dd_py3/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-linux-x86_64.egg/matplotlib/backends/backend_qt5agg.py", line 143, in draw
        FigureCanvasAgg.draw(self)
      File "/home/tcaswell/.virtualenvs/dd_py3/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-linux-x86_64.egg/matplotlib/backends/backend_agg.py", line 475, in draw
        self.figure.draw(self.renderer)
      File "/home/tcaswell/.virtualenvs/dd_py3/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-linux-x86_64.egg/matplotlib/artist.py", line 60, in draw_wrapper
        draw(artist, renderer, *args, **kwargs)
      File "/home/tcaswell/.virtualenvs/dd_py3/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-linux-x86_64.egg/matplotlib/figure.py", line 1094, in draw
        func(*args)
      File "/home/tcaswell/.virtualenvs/dd_py3/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-linux-x86_64.egg/matplotlib/artist.py", line 60, in draw_wrapper
        draw(artist, renderer, *args, **kwargs)
      File "/home/tcaswell/.virtualenvs/dd_py3/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-linux-x86_64.egg/matplotlib/axes/_base.py", line 2006, in draw
        self.apply_aspect()
      File "/home/tcaswell/.virtualenvs/dd_py3/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-linux-x86_64.egg/matplotlib/axes/_base.py", line 1193, in apply_aspect
        if aspect_scale_mode == "log":
    UnboundLocalError: local variable 'aspect_scale_mode' referenced before assignment
    
    If you suspect this is an IPython bug, please report it at:
        https://github.com/ipython/ipython/issues
    or send an email to the mailing list at ipython-dev@scipy.org
    
    You can print a more detailed traceback right now with "%tb", or use "%debug"
    to interactively debug it.
    
    Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
        %config Application.verbose_crash=True
    
    Traceback (most recent call last):
      File "/home/tcaswell/.virtualenvs/dd_py3/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-linux-x86_64.egg/matplotlib/backends/backend_qt5.py", line 341, in resizeEvent
        self.draw()
      File "/home/tcaswell/.virtualenvs/dd_py3/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-linux-x86_64.egg/matplotlib/backends/backend_qt5agg.py", line 143, in draw
        FigureCanvasAgg.draw(self)
      File "/home/tcaswell/.virtualenvs/dd_py3/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-linux-x86_64.egg/matplotlib/backends/backend_agg.py", line 475, in draw
        self.figure.draw(self.renderer)
      File "/home/tcaswell/.virtualenvs/dd_py3/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-linux-x86_64.egg/matplotlib/artist.py", line 60, in draw_wrapper
        draw(artist, renderer, *args, **kwargs)
      File "/home/tcaswell/.virtualenvs/dd_py3/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-linux-x86_64.egg/matplotlib/figure.py", line 1094, in draw
        func(*args)
      File "/home/tcaswell/.virtualenvs/dd_py3/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-linux-x86_64.egg/matplotlib/artist.py", line 60, in draw_wrapper
        draw(artist, renderer, *args, **kwargs)
      File "/home/tcaswell/.virtualenvs/dd_py3/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-linux-x86_64.egg/matplotlib/axes/_base.py", line 2006, in draw
        self.apply_aspect()
      File "/home/tcaswell/.virtualenvs/dd_py3/lib/python3.4/site-packages/matplotlib-1.5.dev1-py3.4-linux-x86_64.egg/matplotlib/axes/_base.py", line 1193, in apply_aspect
        if aspect_scale_mode == "log":
    UnboundLocalError: local variable 'aspect_scale_mode' referenced before assignment
    
    If you suspect this is an IPython bug, please report it at:
        https://github.com/ipython/ipython/issues
    or send an email to the mailing list at ipython-dev@scipy.org
    
    You can print a more detailed traceback right now with "%tb", or use "%debug"
    to interactively debug it.
    
    Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
        %config Application.verbose_crash=True

    Some of which wight also be bugs...

    Can you try running this as a script or in a non-notebook ipython session? I suspect that the notebook is snarfing something it should not be...

  4. modified the milestones: , on Jul 16, 2015
  5. QuLogic commented on Jul 19, 2017

    @QuLogic
    Member

    No answer in 2.5 years, so closing. @eyurtsev please re-open or open a new issue if you still have the issue with latest Matplotlib.

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

    API: consistencyConsistency of the matplotlib API, including naming, behavior, defaults, …status: needs clarificationIssues that need more information to resolve.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions