back to the matplotlib-gallery
at https://github.com/rasbt/matplotlib-gallery
%load_ext watermark
%watermark -u -v -d -p matplotlib,numpy
Last updated: 07/10/2015 CPython 3.4.3 IPython 3.2.0 matplotlib 1.4.3 numpy 1.9.2
More info about the %watermark
extension
%matplotlib inline
I won't be a rock star. I will be a legend.
-- Freddie Mercury
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(10)
for i in range(1, 4):
plt.plot(x, i * x**2, label='Group %d' % i)
plt.legend(loc='best')
plt.show()
x = np.arange(10)
for i in range(1, 4):
plt.plot(x, i * x**2, label='Group %d' % i)
plt.legend(loc='best', fancybox=True, shadow=True)
plt.show()
fig = plt.figure()
ax = plt.subplot(111)
x = np.arange(10)
for i in range(1, 4):
ax.plot(x, i * x**2, label='Group %d' % i)
ax.legend(loc='upper center',
bbox_to_anchor=(0.5, # horizontal
1.15),# vertical
ncol=3, fancybox=True)
plt.show()
fig = plt.figure()
ax = plt.subplot(111)
x = np.arange(10)
for i in range(1, 4):
ax.plot(x, i * x**2, label='Group %d' % i)
ax.legend(loc='upper center',
bbox_to_anchor=(1.15, 1.02),
ncol=1, fancybox=True)
plt.show()
x = np.arange(10)
for i in range(1, 4):
plt.plot(x, i * x**2, label='Group %d' % i)
plt.legend(loc='upper right', framealpha=0.1)
plt.show()
from itertools import cycle
x = np.arange(10)
colors = ['blue', 'red', 'green']
color_gen = cycle(colors)
for i in range(1, 4):
plt.scatter(x, i * x**2, label='Group %d' % i, color=next(color_gen))
plt.legend(loc='upper left')
plt.show()
from itertools import cycle
x = np.arange(10)
colors = ['blue', 'red', 'green']
color_gen = cycle(colors)
for i in range(1, 4):
plt.scatter(x, i * x**2, label='Group %d' % i, color=next(color_gen))
plt.legend(loc='upper left', scatterpoints=1)
plt.show()
from itertools import cycle
x = np.arange(10)
colors = ['blue', 'red', 'green']
color_gen = cycle(colors)
for i in range(1, 4):
plt.plot(x, i * x**2, label='Group %d' % i, marker='o')
plt.legend(loc='upper left')
plt.show()
from itertools import cycle
x = np.arange(10)
colors = ['blue', 'red', 'green']
color_gen = cycle(colors)
for i in range(1, 4):
plt.plot(x, i * x**2, label='Group %d' % i, marker='o')
plt.legend(loc='upper left', numpoints=1)
plt.show()