Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b2eba0c

Browse filesBrowse files
committed
DOC: Make colorbar tutorial examples look like colorbars.
- Give the colorbars a reasonable aspect ratio. - Fix a link. - Other minor edits.
1 parent 6169fa2 commit b2eba0c
Copy full SHA for b2eba0c

File tree

Expand file treeCollapse file tree

1 file changed

+10
-7
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+10
-7
lines changed

‎tutorials/colors/colorbar_only.py

Copy file name to clipboardExpand all lines: tutorials/colors/colorbar_only.py
+10-7Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
1111
:class:`~matplotlib.colorbar.ColorbarBase` derives from
1212
:mod:`~matplotlib.cm.ScalarMappable` and puts a colorbar in a specified axes,
13-
so it has everything needed for a standalone colorbar. It can be used as is to
14-
make a colorbar for a given colormap and does not need a mappable object like
13+
so it has everything needed for a standalone colorbar. It can be used as-is to
14+
make a colorbar for a given colormap; it does not need a mappable object like
1515
an image. In this tutorial we will explore what can be done with standalone
1616
colorbar.
1717
@@ -22,14 +22,15 @@
2222
will be used. Then create the colorbar by calling
2323
:class:`~matplotlib.colorbar.ColorbarBase` and specify axis, colormap, norm
2424
and orientation as parameters. Here we create a basic continuous colorbar
25-
with ticks and labels. More information on colorbar api can be found
26-
`here <https://matplotlib.org/api/colorbar_api.html>`.
25+
with ticks and labels. More information on the colorbar API can be found
26+
`here <https://matplotlib.org/api/colorbar_api.html>`_.
2727
"""
2828

2929
import matplotlib.pyplot as plt
3030
import matplotlib as mpl
3131

32-
fig, ax = plt.subplots()
32+
fig, ax = plt.subplots(figsize=(6, 1))
33+
fig.subplots_adjust(bottom=0.5)
3334

3435
cmap = mpl.cm.cool
3536
norm = mpl.colors.Normalize(vmin=5, vmax=10)
@@ -62,7 +63,8 @@
6263
# *extend*, you must specify two extra boundaries. Finally spacing argument
6364
# ensures that intervals are shown on colorbar proportionally.
6465

65-
fig, ax = plt.subplots()
66+
fig, ax = plt.subplots(figsize=(6, 1))
67+
fig.subplots_adjust(bottom=0.5)
6668

6769
cmap = mpl.colors.ListedColormap(['red', 'green', 'blue', 'cyan'])
6870
cmap.set_over('0.25')
@@ -88,7 +90,8 @@
8890
# colorbar with discrete intervals. To make the length of each extension same
8991
# as the length of the interior colors, use ``extendfrac='auto'``.
9092

91-
fig, ax = plt.subplots()
93+
fig, ax = plt.subplots(figsize=(6, 1))
94+
fig.subplots_adjust(bottom=0.5)
9295

9396
cmap = mpl.colors.ListedColormap(['royalblue', 'cyan',
9497
'yellow', 'orange'])

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.