Search
Examples below can be generated by plot_example.m or plot_example.py script in the Tools repository.
plot_example.m
plot_example.py
prepare_figure
import matplotlib.pyplot as plt
close all
plt.close( 'all' )
title( 'My title' )
plt.title( 'My title' )
plot( …, 'DisplayName', 'Legend 1' );
plt.plot( …, label='Legend 1' )
hold on
plot( …, 'DisplayName', 'Legend 2' );
plt.plot( …, label='Legend 2' )
legend();
plt.legend()
imshow
image( rgb_img )
imagesc( grayscale_img )
plt.imshow( img )
axis image
axis equal
plt.axis( 'image' )
plt.axis( 'equal' )
[*] This hides area outside the image.
plot( x, y, … )
plt.plot( x, y, … )
xlabel( 'x' );
plt.xlabel( 'x' )
ylabel( 'y' );
plt.ylabel( 'y' )
text( x, y, '\alpha' )
plt.plot( x, y, 'a' )
Note that Matlab can plot greek numbers using TeX sequences ( '\\alpha', '\\beta', etc.).
from mpl_toolkits import mplot3d
ax = plt.axes( projection='3d' )
plot3( x, y, z, … )
ax.plot3D( x, y, z, … )
text( x, y, z, … )
ax.text3D( x, y, z, … )
axis( 'equal' )
zlabel( 'z' );
ax.set_zlabel( 'z' )
quiver…
quiver(X,Y,dX,dY,0)
plt.quiver(X,Y,dX,dY)
quiver3(X,Y,Z,dX,dY,dZ,0)
ax.quiver3D(X,Y,Z,dX,dY,dZ)
[*] The scaling argument 0 ensures the arrow is of the proper length.
xlabel( 'time [s]' )
plt.xlabel( 'time [s]' )
ylabel( 'distance [m]' )
plt.ylabel( 'distance [m]' )
axis tight
plt.tight_layout()