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

Skip to content

Commit 21ea65f

Browse files
committed
Add bivariate example
1 parent 5c8dc65 commit 21ea65f

File tree

4 files changed

+42
-4
lines changed

4 files changed

+42
-4
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
"""
2+
===========
3+
Bivariate Demo
4+
===========
5+
6+
Plotting bivariate data.
7+
8+
imshow, pcolor, pcolormesh, pcolorfast allows you to plot bivariate data
9+
using a bivaraite colormap.
10+
11+
In this example we use imshow to plot air temperature with surface pressure
12+
alongwith a color square.
13+
"""
14+
import matplotlib.colors as colors
15+
from matplotlib.cbook import get_sample_data
16+
import matplotlib.pyplot as plt
17+
import numpy as np
18+
19+
20+
###############################################################################
21+
# Bivariate plotting demo
22+
# -----------------------
23+
24+
air_temp = np.load(get_sample_data('air_temperature.npy'))
25+
surf_pres = np.load(get_sample_data('surface_pressure.npy'))
26+
27+
fig, ax = plt.subplots()
28+
29+
bivariate = [air_temp, surf_pres]
30+
31+
cax = ax.imshow(bivariate, norm=colors.BivariateNorm(),
32+
cmap=colors.BivariateColormap())
33+
34+
# if input data is bivariate then colorbar automatically draws colorsquare
35+
# instead of colorbar
36+
cbar = fig.colorbar(cax, xlabel='air_temp', ylabel='surf_pres')
37+
38+
plt.show()

lib/matplotlib/axes/_axes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5081,8 +5081,8 @@ def imshow(self, X, cmap=None, norm=None, aspect=None,
50815081
on the Agg, ps and pdf backends. Other backends will fall back to
50825082
'nearest'.
50835083
5084-
norm : `~matplotlib.colors.Normalize`, `matplotlib.colors.BivariateNorm`
5085-
optional, default: None
5084+
norm : `~matplotlib.colors.Normalize`,
5085+
`matplotlib.colors.BivariateNorm` optional, default: None
50865086
A `~matplotlib.colors.Normalize` instance is used to scale
50875087
a 2-D float `X` input to the (0, 1) range for input to the
50885088
`cmap`. If `norm` is None, use the default func:`normalize`.
@@ -5744,8 +5744,8 @@ def pcolorfast(self, *args, **kwargs):
57445744
57455745
*cmap*: [ *None* | Colormap ]
57465746
A :class:`matplotlib.colors.Colormap` or
5747-
:class:`matplotlib.colors.BivariateColormap` instance from cm. If *None*,
5748-
use rc settings.
5747+
:class:`matplotlib.colors.BivariateColormap` instance from cm.
5748+
If *None*, use rc settings.
57495749
57505750
*norm*: [ *None* | Normalize ]
57515751
A :class:`matplotlib.colors.Normalize` or
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)