%pylab will populate the current scope with functions from numpy and matplotlib. inline allows the plots to be displayed directly in the notebook.
In [89]:
%pylab inline
In [91]:
In [ ]:
In [81]:
X=[1,2,3];
Y=[4,6,5];
plot(X, Y, 'bo-')
Out[81]:
In [82]:
plot(X, Y, marker='o', linestyle='--', color='#ff2780', label='legend uses this');
legend(loc='lower left');
In [83]:
# change the fig size
fig = figure(figsize=(10, 5));
plot(X, Y)
xlabel('x axis', fontsize=20)
ylabel('y axis')
title('figure title')
xlim([1,4]);
# or fig.set_figheight(5) later
Out[83]:
In [84]:
#save figure. figsize affects the saved raster figure
fig.set_figwidth(20);
fig.set_figheight(10);
fig.savefig('testplot.png');
fig.savefig('testplot.eps');
In [85]:
# globally changing the font size
font = {'family' : 'monospace',
'weight' : 'bold',
'size' : 15};
rc('font', **font);
rc('lines', linewidth=2);
# plot again
plot(X, Y);
title('some title')
xlabel('my x-axis')
Out[85]:
In [86]:
A = np.random.rand(10,10)
plt.imshow(A)
plt.colorbar()
Out[86]:
In [87]:
plt.imshow(A, interpolation='nearest')
plt.colorbar()
Out[87]:
In [87]: