From 82c4aab0ab5ae1c296e07603e1c3e5b861e537dc Mon Sep 17 00:00:00 2001 From: Paul Hobson Date: Tue, 10 Jan 2017 23:30:23 -0800 Subject: [PATCH 1/4] DOC: explain logscales and imshow (closes #7661) --- doc/users/whats_new/imshow_logscales.rst | 35 ++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 doc/users/whats_new/imshow_logscales.rst diff --git a/doc/users/whats_new/imshow_logscales.rst b/doc/users/whats_new/imshow_logscales.rst new file mode 100644 index 000000000000..74868025af34 --- /dev/null +++ b/doc/users/whats_new/imshow_logscales.rst @@ -0,0 +1,35 @@ +Non-linears scales on image plots +--------------------------------- + +:func:`imshow` now draws data at the requested points in data space after the +application of non-linear scales. + +The image on the left demonstrates the new, correct behavior. +The old behavior can be recreated using :func:`pcolormesh` as +demonstrated on the right. + +Example +``````` +:: + + import numpy as np + import matplotlib.pyplot as plt + + data = np.arange(30).reshape(5, 6) + x = np.linspace(0, 6, 7) + y = 10**np.linspace(0, 5, 6) + X, Y = np.meshgrid(x, y) + + fig, (ax1, ax2) = plt.subplots(ncols=2, figsize=(8, 4)) + + ax1.imshow(data, aspect="auto", extent=(0, 5, 1e0, 1e5), interpolation='nearest') + ax1.set_yscale('log') + ax1.set_title('Using ax.imshow') + + ax2.pcolormesh(x, y, np.flipud(data)) + ax2.set_yscale('log') + ax2.set_title('Using ax.pcolormesh') + ax2.autoscale('tight') + + plt.show() + From 68230b21ecb9b291cd37aab587e159f2b590e1f4 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Mon, 16 Jan 2017 13:16:13 -0500 Subject: [PATCH 2/4] DOC: tweak example + add some extra prose --- doc/users/whats_new/imshow_logscales.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/doc/users/whats_new/imshow_logscales.rst b/doc/users/whats_new/imshow_logscales.rst index 74868025af34..34ac0c67bf9f 100644 --- a/doc/users/whats_new/imshow_logscales.rst +++ b/doc/users/whats_new/imshow_logscales.rst @@ -22,7 +22,7 @@ Example fig, (ax1, ax2) = plt.subplots(ncols=2, figsize=(8, 4)) - ax1.imshow(data, aspect="auto", extent=(0, 5, 1e0, 1e5), interpolation='nearest') + ax1.imshow(data, aspect="auto", extent=(0, 6, 1e0, 1e5), interpolation='nearest') ax1.set_yscale('log') ax1.set_title('Using ax.imshow') @@ -33,3 +33,7 @@ Example plt.show() + +This can be understood by analogy to plotting a histogram with linearly spaced bins +with a logarithmic x-axis. Equal sized bins at will be displayed as wider for small +*x* and narrower for large *x*. From ab978b879fd49ca3a3351dfee1d7034466128409 Mon Sep 17 00:00:00 2001 From: Paul Hobson Date: Mon, 16 Jan 2017 12:31:05 -0800 Subject: [PATCH 3/4] DOC: fix minor typos in img-show logscale blurb --- doc/users/whats_new/imshow_logscales.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/users/whats_new/imshow_logscales.rst b/doc/users/whats_new/imshow_logscales.rst index 34ac0c67bf9f..ddb1daf5cbe4 100644 --- a/doc/users/whats_new/imshow_logscales.rst +++ b/doc/users/whats_new/imshow_logscales.rst @@ -1,5 +1,5 @@ -Non-linears scales on image plots ---------------------------------- +Non-linear scales on image plots +-------------------------------- :func:`imshow` now draws data at the requested points in data space after the application of non-linear scales. @@ -35,5 +35,5 @@ Example This can be understood by analogy to plotting a histogram with linearly spaced bins -with a logarithmic x-axis. Equal sized bins at will be displayed as wider for small +with a logarithmic x-axis. Equal sized bins will be displayed as wider for small *x* and narrower for large *x*. From a9530f6bb164a42e97ad2a87cd814d4cc9c4b695 Mon Sep 17 00:00:00 2001 From: Paul Hobson Date: Mon, 16 Jan 2017 12:35:06 -0800 Subject: [PATCH 4/4] DOC: add non-linear scales blurb to main whats-new --- doc/users/whats_new.rst | 42 ++++++++++++++++++++++++ doc/users/whats_new/imshow_logscales.rst | 39 ---------------------- 2 files changed, 42 insertions(+), 39 deletions(-) delete mode 100644 doc/users/whats_new/imshow_logscales.rst diff --git a/doc/users/whats_new.rst b/doc/users/whats_new.rst index 2f4a04fda5f0..520225a6e840 100644 --- a/doc/users/whats_new.rst +++ b/doc/users/whats_new.rst @@ -212,6 +212,48 @@ setting the private member ``_image_skew_coordinate`` has been removed. Instead, images will obey the transform of the axes on which they are drawn. +Non-linear scales on image plots +```````````````````````````````` + +:func:`imshow` now draws data at the requested points in data space after the +application of non-linear scales. + +The image on the left demonstrates the new, correct behavior. +The old behavior can be recreated using :func:`pcolormesh` as +demonstrated on the right. + +Non-linear scale example +```````````````````````` + +.. plot:: + + import numpy as np + import matplotlib.pyplot as plt + + data = np.arange(30).reshape(5, 6) + x = np.linspace(0, 6, 7) + y = 10**np.linspace(0, 5, 6) + X, Y = np.meshgrid(x, y) + + fig, (ax1, ax2) = plt.subplots(ncols=2, figsize=(8, 4)) + + ax1.imshow(data, aspect="auto", extent=(0, 6, 1e0, 1e5), interpolation='nearest') + ax1.set_yscale('log') + ax1.set_title('Using ax.imshow') + + ax2.pcolormesh(x, y, np.flipud(data)) + ax2.set_yscale('log') + ax2.set_title('Using ax.pcolormesh') + ax2.autoscale('tight') + + plt.show() + + +This can be understood by analogy to plotting a histogram with linearly spaced bins +with a logarithmic x-axis. Equal sized bins will be displayed as wider for small +*x* and narrower for large *x*. + + Support for HiDPI (Retina) displays in the NbAgg and WebAgg backends -------------------------------------------------------------------- diff --git a/doc/users/whats_new/imshow_logscales.rst b/doc/users/whats_new/imshow_logscales.rst deleted file mode 100644 index ddb1daf5cbe4..000000000000 --- a/doc/users/whats_new/imshow_logscales.rst +++ /dev/null @@ -1,39 +0,0 @@ -Non-linear scales on image plots --------------------------------- - -:func:`imshow` now draws data at the requested points in data space after the -application of non-linear scales. - -The image on the left demonstrates the new, correct behavior. -The old behavior can be recreated using :func:`pcolormesh` as -demonstrated on the right. - -Example -``````` -:: - - import numpy as np - import matplotlib.pyplot as plt - - data = np.arange(30).reshape(5, 6) - x = np.linspace(0, 6, 7) - y = 10**np.linspace(0, 5, 6) - X, Y = np.meshgrid(x, y) - - fig, (ax1, ax2) = plt.subplots(ncols=2, figsize=(8, 4)) - - ax1.imshow(data, aspect="auto", extent=(0, 6, 1e0, 1e5), interpolation='nearest') - ax1.set_yscale('log') - ax1.set_title('Using ax.imshow') - - ax2.pcolormesh(x, y, np.flipud(data)) - ax2.set_yscale('log') - ax2.set_title('Using ax.pcolormesh') - ax2.autoscale('tight') - - plt.show() - - -This can be understood by analogy to plotting a histogram with linearly spaced bins -with a logarithmic x-axis. Equal sized bins will be displayed as wider for small -*x* and narrower for large *x*.