import matplotlib.pyplot as plt
import numpy as np
x = np.random.randn(1000)
y = np.random.randn(1000)
color = np.arange(1000)
plt.scatter(x, y, c=color)
plt.colorbar()
import matplotlib.pyplot as plt
import numpy as np
x = np.random.randn(1000)
y = np.random.randn(1000)
color = np.arange(1000)
plt.scatter(x, y, c=color)
plt.colorbar()
from vega_datsets import data
iris = data('iris')
iris.head()
color_map = dict(zip(iris.species.unique(),
['blue', 'green', 'red']))
for species, group in iris.groupby('species'):
plt.scatter(group['petalLength'], group['sepalWidth'],
color=color_map[species],
alpha=0.3, edgecolor=None, label=species)
plt.legend(frameon=True, title='species')
plt.xlabel('petalLength')
plt.ylabel('sepalLength')
color_map = dict(zip(iris.species.unique(),
['blue', 'green', 'red']))
n_panels = len(color_map)
fig, ax = plt.subplots(1, n_panels, figsize=(n_panels * 5, 3),
sharex=True, sharey=True)
for i, (species, group) in enumerate(iris.groupby('species')):
ax[i].scatter(group['petalLength'], group['sepalWidth'],
color=color_map[species], alpha=0.3,
edgecolor=None, label=species)
ax[i].legend(frameon=True, title='species')
plt.xlabel('petalLength')
plt.ylabel('sepalLength')
Declarative visualization lets you think about data and relationships, rather than incidental details.