8000 Changes in colorbar_only tutorial documentation · matplotlib/matplotlib@1a2b58a · GitHub
[go: up one dir, main page]

Skip to content

Commit 1a2b58a

Browse files
committed
Changes in colorbar_only tutorial documentation
1 parent d6b49b9 commit 1a2b58a

File tree

1 file changed

+15
-19
lines changed

1 file changed

+15
-19
lines changed

tutorials/colors/colorbar_only.py

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,26 @@
33
Customized Colorbars Tutorial
44
=============================
55
6-
This tutorial shows how to build colorbars without an attached mappable.
6+
This tutorial shows how to build colorbars without an attached plot.
77
88
"""
99

1010
###############################################################################
1111
# Customized Colorbars
1212
# ====================
1313
#
14-
# `matplotlib.colorbar.ColorbarBase` derives from `ScalarMappable` and puts a
15-
# colorbar in specified axes, it is the base class with standalone colorbar
16-
# drawing functionality. It can be used as-is to make a colorbar for a given
17-
# colormap and does not need a mappable object like an image. In this tutorial
18-
# we will explore what can be done with standalone colorbar.
14+
# ColorbarBase derives from ScalarMappable and puts a colorbar in a specified
15+
# axes, so it has everything needed for a standalone colorbar. It can be used
16+
# as is to make a colorbar for a given colormap and does not need a mappable
17+
# object like an image. In this tutorial we will explore what can be done with
18+
# standalone colorbar.
1919
#
20-
# We will start by making a figure of desired size and adding axis at position
21-
# [left, bottom, width, height] where all quantities are in fractions of figure
22-
# width and height.
20+
# We will start by making a figure of desired size and adding thress axes.
2321

2422
import matplotlib.pyplot as plt
2523
import matplotlib as mpl
2624

27-
fig = plt.figure(figsize=(8, 3))
28-
ax1 = fig.add_axes([0.05, 0.80, 0.9, 0.15])
29-
ax2 = fig.add_axes([0.05, 0.475, 0.9, 0.15])
30-
ax3 = fig.add_axes([0.05, 0.15, 0.9, 0.15])
25+
fig, (ax1, ax2, ax3) = plt.subplots(nrows=3)
3126

3227
###############################################################################
3328
# Basic continuous colorbar
@@ -51,9 +46,9 @@
5146
# Discrete intervals colorbar
5247
# ---------------------------
5348
#
54-
# The second example illustrates the use of a ListedColormap which generates
49+
# The second example illustrates the use of a ListedColormap which generates a
5550
# colormap from a set of listed colors, a BoundaryNorm which generates a
56-
# colormap index based on discrete interval and extended ends to show the
51+
# colormap index based on discrete intervals and extended ends to show the
5752
# "over" and "under" value colors. Over and under are used to display data
5853
# outside of the normalized [0,1] range. Here we pass colors as gray shades as
5954
# a string encoding a float in the 0-1 range.
@@ -87,10 +82,10 @@
8782
# Colorbar with custom extension lengths
8883
# --------------------------------------
8984
#
90-
# Now in the third example we illustrate the use of custom length colorbar
91-
# extensions, used on a colorbar with discrete intervals. Here we pass colors
92-
# as RGB triplet. To make the length of each extension the same as the length
93-
# of the interior colors pass extendfrac argument as auto
85+
# Here we illustrate the use of custom length colorbar extensions, used on a
86+
# colorbar with discrete intervals. Here we pass colors as RGB triplet. To make
87+
# the length of each extension the same as the length of the interior colors
88+
# pass the extendfrac argument as auto.
9489

9590
cmap = mpl.colors.ListedColormap([[0., .4, 1.], [0., .8, 1.],
9691
[1., .8, 0.], [1., .4, 0.]])
@@ -109,4 +104,5 @@
109104
orientation='horizontal')
110105
cb3.set_label('Custom extension lengths, some other units')
111106

107+
plt.tight_layout()
112108
plt.show()

0 commit comments

Comments
 (0)
0