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

Skip to content

Commit 82c4aab

Browse files
committed
DOC: explain logscales and imshow (closes #7661)
1 parent d181f63 commit 82c4aab

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
Non-linears scales on image plots
2+
---------------------------------
3+
4+
:func:`imshow` now draws data at the requested points in data space after the
5+
application of non-linear scales.
6+
7+
The image on the left demonstrates the new, correct behavior.
8+
The old behavior can be recreated using :func:`pcolormesh` as
9+
demonstrated on the right.
10+
11+
Example
12+
```````
13+
::
14+
15+
import numpy as np
16+
import matplotlib.pyplot as plt
17+
18+
data = np.arange(30).reshape(5, 6)
19+
x = np.linspace(0, 6, 7)
20+
y = 10**np.linspace(0, 5, 6)
21+
X, Y = np.meshgrid(x, y)
22+
23+
fig, (ax1, ax2) = plt.subplots(ncols=2, figsize=(8, 4))
24+
25+
ax1.imshow(data, aspect="auto", extent=(0, 5, 1e0, 1e5), interpolation='nearest')
26+
ax1.set_yscale('log')
27+
ax1.set_title('Using ax.imshow')
28+
29+
ax2.pcolormesh(x, y, np.flipud(data))
30+
ax2.set_yscale('log')
31+
ax2.set_title('Using ax.pcolormesh')
32+
ax2.autoscale('tight')
33+
34+
plt.show()
35+

0 commit comments

Comments
 (0)