Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
eyurtsev opened this issue Dec 17, 2014 · 2 comments
Labels
API: consistency status: needs clarification Issues that need more information to resolve.
Milestone

Comments

@eyurtsev
Copy link
Contributor

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)
@tacaswell tacaswell added this to the next point release milestone Feb 19, 2015
@tacaswell
Copy link
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...

@tacaswell tacaswell added the status: needs clarification Issues that need more information to resolve. label Feb 19, 2015
@tacaswell tacaswell modified the milestones: next point release, proposed next point release Jul 16, 2015
@QuLogic
Copy link
Member

QuLogic commented Jul 19, 2017

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.

@QuLogic QuLogic closed this as completed Jul 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API: consistency status: needs clarification Issues that need more information to resolve.
Projects
None yet
Development

No branches or pull requests

3 participants