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

Skip to content

Commit 70d138a

Browse files
committed
Cleanup contour_demo.
1 parent 9984f9c commit 70d138a

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

examples/images_contours_and_fields/contour_demo.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
See also the :doc:`contour image example
1010
</gallery/images_contours_and_fields/contour_image>`.
1111
"""
12+
1213
import matplotlib
1314
import numpy as np
1415
import matplotlib.cm as cm
@@ -24,29 +25,27 @@
2425
Z = (Z1 - Z2) * 2
2526

2627
###############################################################################
27-
# Create a simple contour plot with labels using default colors. The
28-
# inline argument to clabel will control whether the labels are draw
29-
# over the line segments of the contour, removing the lines beneath
30-
# the label
28+
# Create a simple contour plot with labels using default colors. The inline
29+
# argument to clabel will control whether the labels are draw over the line
30+
# segments of the contour, removing the lines beneath the label.
3131

3232
fig, ax = plt.subplots()
3333
CS = ax.contour(X, Y, Z)
3434
ax.clabel(CS, inline=1, fontsize=10)
3535
ax.set_title('Simplest default with labels')
3636

37-
3837
###############################################################################
39-
# contour labels can be placed manually by providing list of positions
40-
# (in data coordinate). See ginput_manual_clabel.py for interactive
41-
# placement.
38+
# Contour labels can be placed manually by providing list of positions (in data
39+
# coordinate). See :doc:`/gallery/event_handling/ginput_manual_clabel_sgskip`
40+
# for interactive placement.
4241

4342
fig, ax = plt.subplots()
4443
CS = ax.contour(X, Y, Z)
45-
manual_locations = [(-1, -1.4), (-0.62, -0.7), (-2, 0.5), (1.7, 1.2), (2.0, 1.4), (2.4, 1.7)]
44+
manual_locations = [
45+
(-1, -1.4), (-0.62, -0.7), (-2, 0.5), (1.7, 1.2), (2.0, 1.4), (2.4, 1.7)]
4646
ax.clabel(CS, inline=1, fontsize=10, manual=manual_locations)
4747
ax.set_title('labels at selected locations')
4848

49-
5049
###############################################################################
5150
# You can force all the contours to be the same color.
5251

@@ -64,7 +63,6 @@
6463
ax.clabel(CS, fontsize=9, inline=1)
6564
ax.set_title('Single color - negative contours solid')
6665

67-
6866
###############################################################################
6967
# And you can manually specify the colors of the contour
7068

@@ -76,14 +74,13 @@
7674
ax.clabel(CS, fontsize=9, inline=1)
7775
ax.set_title('Crazy lines')
7876

79-
8077
###############################################################################
8178
# Or you can use a colormap to specify the colors; the default
8279
# colormap will be used for the contour lines
8380

8481
fig, ax = plt.subplots()
8582
im = ax.imshow(Z, interpolation='bilinear', origin='lower',
86-
cmap=cm.gray, extent=(-3, 3, -2, 2))
83+
cmap=cm.gray, extent=(-3, 3, -2, 2))
8784
levels = np.arange(-1.2, 1.6, 0.2)
8885
CS = ax.contour(Z, levels, origin='lower', cmap='flag',
8986
linewidths=2, extent=(-3, 3, -2, 2))

0 commit comments

Comments
 (0)