Skip to content

Commit

Permalink
replace scipy.misc in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jlaehne committed Sep 6, 2023
1 parent fa7a7e0 commit dea3de2
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 83 deletions.
14 changes: 7 additions & 7 deletions doc/user_guide/region_of_interest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ added before calling :py:meth:`~.roi.BaseInteractiveROI.interactive`.

.. code-block:: python
>>> import scipy.misc
>>> im = hs.signals.Signal2D(scipy.misc.ascent())
>>> import scipy.datasets
>>> im = hs.signals.Signal2D(scipy.datasets.ascent())
>>> rectangular_roi = hs.roi.RectangularROI(left=30, right=500,
... top=200, bottom=400)
>>> line_roi = hs.roi.Line2DROI(0, 0, 512, 512, 1)
Expand Down Expand Up @@ -78,8 +78,8 @@ can be plotted on a different signal altogether.

.. code-block:: python
>>> import scipy.misc
>>> im = hs.signals.Signal2D(scipy.misc.ascent())
>>> import scipy.datasets
>>> im = hs.signals.Signal2D(scipy.datasets.ascent())
>>> s = hs.signals.Signal1D(np.random.rand(512, 512, 512))
>>> roi = hs.roi.RectangularROI(left=30, right=77, top=20, bottom=50)
>>> s.plot() # plot signal to have where to display the widget
Expand Down Expand Up @@ -110,8 +110,8 @@ order to increase responsiveness.

.. code-block:: python
>>> import scipy.misc
>>> im = hs.signals.Signal2D(scipy.misc.ascent())
>>> import scipy.datasets
>>> im = hs.signals.Signal2D(scipy.datasets.ascent())
>>> im.plot()
>>> roi = hs.roi.RectangularROI(left=30, right=500, top=200, bottom=400)
>>> im_roi = roi.interactive(im, color="red")
Expand Down Expand Up @@ -195,7 +195,7 @@ ROIs can be used in place of slices when indexing. For example:

.. code-block:: python
>>> s = hs.datasets.example_signals.EDS_TEM_Spectrum()
>>> s = hs.datasets.ascent.example_signals.EDS_TEM_Spectrum()
>>> roi = hs.roi.SpanROI(left=5, right=15)
>>> sc = s.isig[roi]
>>> im = hs.signals.Signal2D(scipy.datasets.ascent())
Expand Down
10 changes: 5 additions & 5 deletions doc/user_guide/signal/generic_tools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ to make a horizontal "collage" of the image stack:
.. code-block:: python
>>> import scipy.ndimage
>>> image_stack = hs.signals.Signal2D(np.array([scipy.misc.ascent()]*5))
>>> image_stack = hs.signals.Signal2D(np.array([scipy.datasets.ascent()]*5))
>>> image_stack.axes_manager[1].name = "x"
>>> image_stack.axes_manager[2].name = "y"
>>> for image, angle in zip(image_stack, (0, 45, 90, 135, 180)):
Expand Down Expand Up @@ -270,7 +270,7 @@ using an external function can be more easily accomplished using the
.. code-block:: python
>>> import scipy.ndimage
>>> image_stack = hs.signals.Signal2D(np.array([scipy.misc.ascent()]*4))
>>> image_stack = hs.signals.Signal2D(np.array([scipy.datasets.ascent()]*4))
>>> image_stack.axes_manager[1].name = "x"
>>> image_stack.axes_manager[2].name = "y"
>>> image_stack.map(scipy.ndimage.rotate,
Expand All @@ -293,7 +293,7 @@ arguments as in the following example.
.. code-block:: python
>>> import scipy.ndimage
>>> image_stack = hs.signals.Signal2D(np.array([scipy.misc.ascent()]*4))
>>> image_stack = hs.signals.Signal2D(np.array([scipy.datasets.ascent()]*4))
>>> image_stack.axes_manager[1].name = "x"
>>> image_stack.axes_manager[2].name = "y"
>>> angles = hs.signals.BaseSignal(np.array([0, 45, 90, 135]))
Expand Down Expand Up @@ -325,7 +325,7 @@ data (default, ``True``) or storing it to a new signal (``False``).
.. code-block:: python
>>> import scipy.ndimage
>>> image_stack = hs.signals.Signal2D(np.array([scipy.misc.ascent()]*4))
>>> image_stack = hs.signals.Signal2D(np.array([scipy.datasets.ascent()]*4))
>>> angles = hs.signals.BaseSignal(np.array([0, 45, 90, 135]))
>>> result = image_stack.map(scipy.ndimage.rotate,
... angle=angles.T,
Expand Down Expand Up @@ -589,7 +589,7 @@ with same dimension.
.. code-block:: python
>>> image = hs.signals.Signal2D(scipy.misc.ascent())
>>> image = hs.signals.Signal2D(scipy.datasets.ascent())
>>> image = hs.stack([hs.stack([image]*3,axis=0)]*3,axis=1)
>>> image.plot()
Expand Down
80 changes: 40 additions & 40 deletions doc/user_guide/visualisation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ Colorbar, scalebar and contrast controls are HyperSpy-specific, however
.. code-block:: python
>>> import scipy
>>> img = hs.signals.Signal2D(scipy.misc.ascent())
>>> img = hs.signals.Signal2D(scipy.datasets.ascent())
>>> img.plot(colorbar=True, scalebar=False,
... axes_ticks=True, cmap='RdYlBu_r')
Expand Down Expand Up @@ -308,7 +308,7 @@ the section :ref:`plot.customize_images` can be passed as a dictionary to the
>>> import numpy as np
>>> import scipy
>>> im = hs.signals.Signal2D(scipy.misc.ascent())
>>> im = hs.signals.Signal2D(scipy.datasets.ascent())
>>> ims = hs.signals.BaseSignal(np.random.rand(15,13)).T * im
>>> ims.metadata.General.title = 'My Images'
>>> ims.plot(colorbar=False,
Expand Down Expand Up @@ -521,7 +521,7 @@ different slices of a multidimensional image (a *hyperimage*):
.. code-block:: python
>>> import scipy
>>> image = hs.signals.Signal2D([scipy.misc.ascent()]*6)
>>> image = hs.signals.Signal2D([scipy.datasets.ascent()]*6)
>>> angles = hs.signals.BaseSignal(range(10,70,10))
>>> image.map(scipy.ndimage.rotate, angle=angles.T, reshape=False)
>>> hs.plot.plot_images(image, tight_layout=True)
Expand All @@ -544,7 +544,7 @@ axes labels and the ticks are also disabled with `axes_decor`:
.. code-block:: python
>>> import scipy
>>> image = hs.signals.Signal2D([scipy.misc.ascent()]*6)
>>> image = hs.signals.Signal2D([scipy.datasets.ascent()]*6)
>>> angles = hs.signals.BaseSignal(range(10,70,10))
>>> image.map(scipy.ndimage.rotate, angle=angles.T, reshape=False)
>>> hs.plot.plot_images(
Expand All @@ -571,22 +571,22 @@ multiple individual ones:
>>> import numpy as np
>>>
>>> # load red channel of raccoon as an image
>>> image0 = hs.signals.Signal2D(scipy.misc.face()[:,:,0])
>>> image0 = hs.signals.Signal2D(scipy.datasets.face()[:,:,0])
>>> image0.metadata.General.title = 'Rocky Raccoon - R'
>>>
>>> # load ascent into a length 6 hyper-image
>>> image1 = hs.signals.Signal2D([scipy.misc.ascent()]*6)
>>> image1 = hs.signals.Signal2D([scipy.datasets.ascent()]*6)
>>> angles = hs.signals.BaseSignal(np.arange(10,70,10)).T
>>> image1.map(scipy.ndimage.rotate, angle=angles,
... show_progressbar=False, reshape=False)
>>> image1.data = np.clip(image1.data, 0, 255) # clip data to int range
>>>
>>> # load green channel of raccoon as an image
>>> image2 = hs.signals.Signal2D(scipy.misc.face()[:,:,1])
>>> image2 = hs.signals.Signal2D(scipy.datasets.face()[:,:,1])
>>> image2.metadata.General.title = 'Rocky Raccoon - G'
>>>
>>> # load rgb image of the raccoon
>>> rgb = hs.signals.Signal1D(scipy.misc.face())
>>> rgb = hs.signals.Signal1D(scipy.datasets.face())
>>> rgb.change_dtype("rgb8")
>>> rgb.metadata.General.title = 'Raccoon - RGB'
>>>
Expand Down Expand Up @@ -819,8 +819,8 @@ a file:

.. code-block:: python
>>> import scipy.misc
>>> s = hs.signals.Signal1D(scipy.misc.ascent()[100:160:10])
>>> import scipy.datasets
>>> s = hs.signals.Signal1D(scipy.datasets.ascent()[100:160:10])
>>> cascade_plot = hs.plot.plot_spectra(s, style='cascade')
>>> cascade_plot.figure.savefig("cascade_plot.png")
Expand All @@ -841,8 +841,8 @@ and provide the legend labels:

.. code-block:: python
>>> import scipy.misc
>>> s = hs.signals.Signal1D(scipy.misc.ascent()[100:160:10])
>>> import scipy.datasets
>>> s = hs.signals.Signal1D(scipy.datasets.ascent()[100:160:10])
>>> color_list = ['red', 'red', 'blue', 'blue', 'red', 'red']
>>> linestyle_list = ['-', '--', '-.', ':', '-']
>>> hs.plot.plot_spectra(s, style='cascade', color=color_list,
Expand All @@ -861,10 +861,10 @@ generate a list of colors that follows a certain colormap:

.. code-block:: python
>>> import scipy.misc
>>> import scipy.datasets
>>> fig, axarr = plt.subplots(1,2)
>>> s1 = hs.signals.Signal1D(scipy.misc.ascent()[100:160:10])
>>> s2 = hs.signals.Signal1D(scipy.misc.ascent()[200:260:10])
>>> s1 = hs.signals.Signal1D(scipy.datasets.ascent()[100:160:10])
>>> s2 = hs.signals.Signal1D(scipy.datasets.ascent()[200:260:10])
>>> hs.plot.plot_spectra(s1,
... style='cascade',
... color=[plt.cm.RdBu(i/float(len(s1)-1))
Expand Down Expand Up @@ -892,8 +892,8 @@ There are also two other styles, "heatmap" and "mosaic":

.. code-block:: python
>>> import scipy.misc
>>> s = hs.signals.Signal1D(scipy.misc.ascent()[100:160:10])
>>> import scipy.datasets
>>> s = hs.signals.Signal1D(scipy.datasets.ascent()[100:160:10])
>>> hs.plot.plot_spectra(s, style='heatmap')
.. figure:: images/plot_spectra_heatmap.png
Expand All @@ -905,8 +905,8 @@ There are also two other styles, "heatmap" and "mosaic":

.. code-block:: python
>>> import scipy.misc
>>> s = hs.signals.Signal1D(scipy.misc.ascent()[100:120:10])
>>> import scipy.datasets
>>> s = hs.signals.Signal1D(scipy.datasets.ascent()[100:120:10])
>>> hs.plot.plot_spectra(s, style='mosaic')
.. figure:: images/plot_spectra_mosaic.png
Expand All @@ -923,8 +923,8 @@ can be used:
.. code-block:: python
>>> import matplotlib.cm
>>> import scipy.misc
>>> s = hs.signals.Signal1D(scipy.misc.ascent()[100:120:10])
>>> import scipy.datasets
>>> s = hs.signals.Signal1D(scipy.datasets.ascent()[100:120:10])
>>> ax = hs.plot.plot_spectra(s, style="heatmap")
>>> ax.images[0].set_cmap(matplotlib.cm.plasma)
Expand All @@ -943,8 +943,8 @@ directly to matplotlib.pyplot.figure as keyword arguments:

.. code-block:: python
>>> import scipy.misc
>>> s = hs.signals.Signal1D(scipy.misc.ascent()[100:160:10])
>>> import scipy.datasets
>>> s = hs.signals.Signal1D(scipy.datasets.ascent()[100:160:10])
>>> legendtext = ['Plot 0', 'Plot 1', 'Plot 2', 'Plot 3',
... 'Plot 4', 'Plot 5']
>>> cascade_plot = hs.plot.plot_spectra(
Expand All @@ -966,8 +966,8 @@ the figure:

.. code-block:: python
>>> import scipy.misc
>>> s = hs.signals.Signal1D(scipy.misc.ascent()[100:160:10])
>>> import scipy.datasets
>>> s = hs.signals.Signal1D(scipy.datasets.ascent()[100:160:10])
>>> cascade_plot = hs.plot.plot_spectra(s)
>>> cascade_plot.set_xlabel("An axis")
>>> cascade_plot.set_ylabel("Another axis")
Expand All @@ -986,10 +986,10 @@ and "overlap" styles:

.. code-block:: python
>>> import scipy.misc
>>> import scipy.datasets
>>> fig, axarr = plt.subplots(1,2)
>>> s1 = hs.signals.Signal1D(scipy.misc.ascent()[100:160:10])
>>> s2 = hs.signals.Signal1D(scipy.misc.ascent()[200:260:10])
>>> s1 = hs.signals.Signal1D(scipy.datasets.ascent()[100:160:10])
>>> s2 = hs.signals.Signal1D(scipy.datasets.ascent()[200:260:10])
>>> hs.plot.plot_spectra(s1, style='cascade',
... color='blue', ax=axarr[0], fig=fig)
>>> hs.plot.plot_spectra(s2, style='cascade',
Expand Down Expand Up @@ -1047,8 +1047,8 @@ same time:

.. code-block:: python
>>> import scipy.misc
>>> s1 = hs.signals.Signal1D(scipy.misc.face()).as_signal1D(0).inav[:,:3]
>>> import scipy.datasets
>>> s1 = hs.signals.Signal1D(scipy.datasets.face()).as_signal1D(0).inav[:,:3]
>>> s2 = s1.deepcopy()*-1
>>> hs.plot.plot_signals([s1, s2])
Expand All @@ -1067,8 +1067,8 @@ To specify the navigator:

.. code-block:: python
>>> import scipy.misc
>>> s1 = hs.signals.Signal1D(scipy.misc.face()).as_signal1D(0).inav[:,:3]
>>> import scipy.datasets
>>> s1 = hs.signals.Signal1D(scipy.datasets.face()).as_signal1D(0).inav[:,:3]
>>> s2 = s1.deepcopy()*-1
>>> hs.plot.plot_signals([s1, s2], navigator="slider")
Expand All @@ -1085,8 +1085,8 @@ For example:

.. code-block:: python
>>> import scipy.misc
>>> s1 = hs.signals.Signal1D(scipy.misc.face()).as_signal1D(0).inav[:,:3]
>>> import scipy.datasets
>>> s1 = hs.signals.Signal1D(scipy.datasets.face()).as_signal1D(0).inav[:,:3]
>>> s2 = s1.deepcopy()*-1
>>> s3 = hs.signals.Signal1D(np.linspace(0,9,9).reshape([3,3]))
>>> hs.plot.plot_signals([s1, s2], navigator_list=["slider", s3])
Expand All @@ -1104,8 +1104,8 @@ each plot:

.. code-block:: python
>>> import scipy.misc
>>> s1 = hs.signals.Signal1D(scipy.misc.face()).as_signal1D(0)[:,:3]
>>> import scipy.datasets
>>> s1 = hs.signals.Signal1D(scipy.datasets.face()).as_signal1D(0)[:,:3]
>>> s2 = s1.deepcopy()*-1
>>> hs.plot.plot_signals([s1, s2], sync=False,
... navigator_list=["slider", "slider"])
Expand All @@ -1126,8 +1126,8 @@ can be used in a static way

.. code-block:: python
>>> import scipy.misc
>>> im = hs.signals.Signal2D(scipy.misc.ascent())
>>> import scipy.datasets
>>> im = hs.signals.Signal2D(scipy.datasets.ascent())
>>> m = hs.plot.markers.Rectangle(x1=150, y1=100, x2=400, y2=400, color='red')
>>> im.add_marker(m)
Expand All @@ -1144,8 +1144,8 @@ for each R, G and B channel of a colour image.
.. code-block:: python
>>> from skimage.feature import peak_local_max
>>> import scipy.misc
>>> ims = hs.signals.BaseSignal(scipy.misc.face()).as_signal2D([1,2])
>>> import scipy.datasets
>>> ims = hs.signals.BaseSignal(scipy.datasets.face()).as_signal2D([1,2])
>>> index = np.array([peak_local_max(im.data, min_distance=100,
... num_peaks=4)
... for im in ims])
Expand Down
Loading

0 comments on commit dea3de2

Please sign in to comment.