Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cfafd3d

Browse filesBrowse files
efiringtacaswell
authored andcommitted
Merge pull request matplotlib#7800 from phobson/doc-imshow-logscale
DOC: explain non-linear scales and imshow (closes matplotlib#7661)
1 parent 4e1df0b commit cfafd3d
Copy full SHA for cfafd3d

File tree

Expand file treeCollapse file tree

1 file changed

+42
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+42
-0
lines changed

‎doc/users/whats_new.rst

Copy file name to clipboardExpand all lines: doc/users/whats_new.rst
+42Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,48 @@ setting the private member ``_image_skew_coordinate`` has been
212212
removed. Instead, images will obey the transform of the axes on which
213213
they are drawn.
214214

215+
Non-linear scales on image plots
216+
````````````````````````````````
217+
218+
:func:`imshow` now draws data at the requested points in data space after the
219+
application of non-linear scales.
220+
221+
The image on the left demonstrates the new, correct behavior.
222+
The old behavior can be recreated using :func:`pcolormesh` as
223+
demonstrated on the right.
224+
225+
Non-linear scale example
226+
````````````````````````
227+
228+
.. plot::
229+
230+
import numpy as np
231+
import matplotlib.pyplot as plt
232+
233+
data = np.arange(30).reshape(5, 6)
234+
x = np.linspace(0, 6, 7)
235+
y = 10**np.linspace(0, 5, 6)
236+
X, Y = np.meshgrid(x, y)
237+
238+
fig, (ax1, ax2) = plt.subplots(ncols=2, figsize=(8, 4))
239+
240+
ax1.imshow(data, aspect="auto", extent=(0, 6, 1e0, 1e5), interpolation='nearest')
241+
ax1.set_yscale('log')
242+
ax1.set_title('Using ax.imshow')
243+
244+
ax2.pcolormesh(x, y, np.flipud(data))
245+
ax2.set_yscale('log')
246+
ax2.set_title('Using ax.pcolormesh')
247+
ax2.autoscale('tight')
248+
249+
plt.show()
250+
251+
252+
This can be understood by analogy to plotting a histogram with linearly spaced bins
253+
with a logarithmic x-axis. Equal sized bins will be displayed as wider for small
254+
*x* and narrower for large *x*.
255+
256+
215257

216258
Support for HiDPI (Retina) displays in the NbAgg and WebAgg backends
217259
--------------------------------------------------------------------

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.