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

Skip to content

DOC: Adding example references for Images,contours,fields section #11191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions examples/images_contours_and_fields/affine_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
Affine transform of an image
============================


Prepending an affine transformation (:class:`~.transforms.Affine2D`)
to the :ref:`data transform <data-coords>`
of an image allows to manipulate the image's shape and orientation.
This is an example of the concept of
:ref:`transform chaining <transformation-pipeline>`.

For the backends that support draw_image with optional affine
transform (e.g., agg, ps backend), the image of the output should
have its boundary match the dashed yellow rectangle.
Expand Down Expand Up @@ -57,3 +64,19 @@ def do_plot(ax, Z, transform):
rotate_deg(30).skew_deg(30, 15).scale(-1, .5).translate(.5, -1))

plt.show()


#############################################################################
#
# ------------
#
# References
# """"""""""
#
# The use of the following functions, methods and classes is shown
# in this example:

import matplotlib
matplotlib.axes.Axes.imshow
matplotlib.pyplot.imshow
matplotlib.transforms.Affine2D
15 changes: 15 additions & 0 deletions examples/images_contours_and_fields/barb_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,18 @@
ax2.barbs(data['x'], data['y'], masked_u, data['v'], length=8, pivot='middle')

plt.show()

#############################################################################
#
# ------------
#
# References
# """"""""""
#
# The use of the following functions, methods and classes is shown
# in this example:

import matplotlib
matplotlib.axes.Axes.barbs
matplotlib.pyplot.barbs

17 changes: 16 additions & 1 deletion examples/images_contours_and_fields/barcode_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Barcode Demo
============

This demo shows how to produce a one-dimensional image, or "bar code".
"""
import matplotlib.pyplot as plt
import numpy as np
Expand All @@ -19,7 +20,7 @@

fig = plt.figure()

# a vertical barcode -- this is broken at present
# a vertical barcode
ax1 = fig.add_axes([0.1, 0.3, 0.1, 0.6], **axprops)
ax1.imshow(x.reshape((-1, 1)), **barprops)

Expand All @@ -29,3 +30,17 @@


plt.show()

#############################################################################
#
# ------------
#
# References
# """"""""""
#
# The use of the following functions, methods and classes is shown
# in this example:

import matplotlib
matplotlib.axes.Axes.imshow
matplotlib.pyplot.imshow
20 changes: 18 additions & 2 deletions examples/images_contours_and_fields/contour_corner_mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
Contour Corner Mask
===================

Illustrate the difference between corner_mask=False and corner_mask=True
for masked contour plots.
Illustrate the difference between ``corner_mask=False`` and
``corner_mask=True`` for masked contour plots.
"""
import matplotlib.pyplot as plt
import numpy as np
Expand Down Expand Up @@ -36,3 +36,19 @@
ax.plot(np.ma.array(x, mask=~mask), y, 'ro')

plt.show()

#############################################################################
#
# ------------
#
# References
# """"""""""
#
# The use of the following functions and methods is shown
# in this example:

import matplotlib
matplotlib.axes.Axes.contour
matplotlib.pyplot.contour
matplotlib.axes.Axes.contourf
matplotlib.pyplot.contourf
26 changes: 23 additions & 3 deletions examples/images_contours_and_fields/contour_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
Illustrate simple contour plotting, contours on an image with
a colorbar for the contours, and labelled contours.

See also contour_image.py.
See also the
:ref:`contour image example
<sphx_glr_gallery_images_contours_and_fields_contour_image.py>`.
"""
import matplotlib
import numpy as np
import matplotlib.cm as cm
import matplotlib.pyplot as plt

matplotlib.rcParams['xtick.direction'] = 'out'
matplotlib.rcParams['ytick.direction'] = 'out'

delta = 0.025
x = np.arange(-3.0, 3.0, delta)
Expand Down Expand Up @@ -116,3 +116,23 @@
CB.ax.set_position([ll, b + 0.1*h, ww, h*0.8])

plt.show()

#############################################################################
#
# ------------
#
# References
# """"""""""
#
# The use of the following functions and methods is shown
# in this example:

import matplotlib
matplotlib.axes.Axes.contour
matplotlib.pyplot.contour
matplotlib.figure.Figure.colorbar
matplotlib.pyplot.colorbar
matplotlib.axes.Axes.clabel
matplotlib.pyplot.clabel
matplotlib.axes.Axes.set_position
matplotlib.axes.Axes.get_position
28 changes: 26 additions & 2 deletions examples/images_contours_and_fields/contour_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@
=============

Test combinations of contouring, filled contouring, and image plotting.
For contour labelling, see contour_demo.py.
For contour labelling, see See also the
:ref:`contour demo example
<sphx_glr_gallery_images_contours_and_fields_contour_demo.py>`.

The emphasis in this demo is on showing how to make contours register
correctly on images, and on how to get both of them oriented as
desired. In particular, note the usage of the "origin" and "extent"
desired. In particular, note the usage of the
:ref:`"origin" and "extent"
<sphx_glr_tutorials_intermediate_imshow_extent.py>`
keyword arguments to imshow and contour.
"""
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -91,3 +95,23 @@

fig.tight_layout()
plt.show()


#############################################################################
#
# ------------
#
# References
# """"""""""
#
# The use of the following functions, methods and classes is shown
# in this example:

import matplotlib
matplotlib.axes.Axes.contour
matplotlib.pyplot.contour
matplotlib.axes.Axes.imshow
matplotlib.pyplot.imshow
matplotlib.figure.Figure.colorbar
matplotlib.pyplot.colorbar
matplotlib.colors.Normalize
23 changes: 19 additions & 4 deletions examples/images_contours_and_fields/contour_label_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
Illustrate some of the more advanced things that one can do with
contour labels.

See also contour_demo.py.
See also the :ref:`contour demo example
<sphx_glr_gallery_images_contours_and_fields_contour_demo.py>`.
"""

import matplotlib
Expand All @@ -15,9 +16,6 @@
import matplotlib.ticker as ticker
import matplotlib.pyplot as plt

matplotlib.rcParams['xtick.direction'] = 'out'
matplotlib.rcParams['ytick.direction'] = 'out'

###############################################################################
# Define our surface

Expand Down Expand Up @@ -89,3 +87,20 @@ def __repr__(self):
ax2.set_title("$100^Z$")

plt.show()

#############################################################################
#
# ------------
#
# References
# """"""""""
#
# The use of the following functions, methods and classes is shown
# in this example:

matplotlib.axes.Axes.contour
matplotlib.pyplot.contour
matplotlib.axes.Axes.clabel
matplotlib.pyplot.clabel
matplotlib.ticker.LogFormatterMathtext
matplotlib.ticker.TickHelper.create_dummy_axis
26 changes: 25 additions & 1 deletion examples/images_contours_and_fields/contourf_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Contourf Demo
=============

How to use the ``contourf`` function to create filled contour plots.
How to use the :meth:`.axes.Axes.contourf` method to create filled contour plots.
"""
import numpy as np
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -105,3 +105,27 @@
ax.locator_params(nbins=4)

plt.show()

#############################################################################
#
# ------------
#
# References
# """"""""""
#
# The use of the following functions, methods and classes is shown
# in this example:

import matplotlib
matplotlib.axes.Axes.contour
matplotlib.pyplot.contour
matplotlib.axes.Axes.contourf
matplotlib.pyplot.contourf
matplotlib.axes.Axes.clabel
matplotlib.pyplot.clabel
matplotlib.figure.Figure.colorbar
matplotlib.pyplot.colorbar
matplotlib.colors.Colormap
matplotlib.colors.Colormap.set_bad
matplotlib.colors.Colormap.set_under
matplotlib.colors.Colormap.set_over
22 changes: 22 additions & 0 deletions examples/images_contours_and_fields/contourf_hatching.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,25 @@
artists, labels = cs.legend_elements()
ax2.legend(artists, labels, handleheight=2)
plt.show()

#############################################################################
#
# ------------
#
# References
# """"""""""
#
# The use of the following functions, methods and classes is shown
# in this example:

import matplotlib
matplotlib.axes.Axes.contour
matplotlib.pyplot.contour
matplotlib.axes.Axes.contourf
matplotlib.pyplot.contourf
matplotlib.figure.Figure.colorbar
matplotlib.pyplot.colorbar
matplotlib.axes.Axes.legend
matplotlib.pyplot.legend
matplotlib.contour.ContourSet
matplotlib.contour.ContourSet.legend_elements
19 changes: 19 additions & 0 deletions examples/images_contours_and_fields/contourf_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,22 @@
cbar = fig.colorbar(cs)

plt.show()

#############################################################################
#
# ------------
#
# References
# """"""""""
#
# The use of the following functions, methods and classes is shown
# in this example:

import matplotlib
matplotlib.axes.Axes.contourf
matplotlib.pyplot.contourf
matplotlib.figure.Figure.colorbar
matplotlib.pyplot.colorbar
matplotlib.axes.Axes.legend
matplotlib.pyplot.legend
matplotlib.ticker.LogLocator
31 changes: 28 additions & 3 deletions examples/images_contours_and_fields/custom_cmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
Creating a colormap from a list of colors
=========================================

Creating a colormap from a list of colors can be done with the `from_list`
method of `LinearSegmentedColormap`. You must pass a list of RGB tuples that
define the mixture of colors from 0 to 1.
Creating a :ref:`colormap <sphx_glr_tutorials_colors_colormaps.py>`
from a list of colors can be done with the
:meth:`~.colors.LinearSegmentedColormap.from_list` method of
`LinearSegmentedColormap`. You must pass a list of RGB tuples that define the
mixture of colors from 0 to 1.


Creating custom colormaps
Expand Down Expand Up @@ -223,3 +225,26 @@
fig.subplots_adjust(top=0.9)

plt.show()

#############################################################################
#
# ------------
#
# References
# """"""""""
#
# The use of the following functions, methods, classes and modules is shown
# in this example:

import matplotlib
matplotlib.axes.Axes.imshow
matplotlib.pyplot.imshow
matplotlib.figure.Figure.colorbar
matplotlib.pyplot.colorbar
matplotlib.colors
matplotlib.colors.LinearSegmentedColormap
matplotlib.colors.LinearSegmentedColormap.from_list
matplotlib.cm
matplotlib.cm.ScalarMappable.set_cmap
matplotlib.pyplot.register_cmap
matplotlib.cm.register_cmap
Loading