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

Skip to content

document that imshow now respects scale #7661

Closed
@PrometheusPi

Description

@PrometheusPi

With the introduction of matplotlib 2.0.0 using plt.imshow() together with plt.yscale('log') changed its behavior.

The following example code:

import numpy as np
import matplotlib.pyplot as plt

tmp = np.random.random((5,5))
plt.imshow(tmp, aspect="auto", extent=(0,5, 1e0, 1e5), interpolation='nearest')
plt.yscale("log")

plt.show()

produces with python 3.4.3 and matplotlib 1.5.1
plt_imshow_2

and the following warning:

../.local/lib/python3.4/site-packages/matplotlib/image.py:375: UserWarning: Images are not supported on non-linear axes.
  warnings.warn("Images are not supported on non-linear axes.")

With python 3.4.3 and matplotlib 2.0.0rc1 it produces
index2

Thus, 2.0.0 assumes that underneath the linear bin id of the numpy array tmp lies a linear data extend (y-axis) scaling.

If however my logarithmic extent is mapped correctly onto the linear bin id of the numpy array - the old behavior is exactly what represents the data.

Is it possible to reproduce the old behavior without relabeling the y-axis by hand?
Is there an option, the tell imshow directly that a specify data axis is already log-scaled?

and if so:
Is it possible to have the same behavior independent of the matplotlib version used?

System:
Ubuntu 14.04.5 - Linux-Kernel 4.4.0-38
Matplotlib and Python are available via the HPC module system (probably via pip)

cc'ing: @s0vereign

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions