Matplotlib Notes
Matplotlib Notes
0. MOTIVATION
1. BASICS
1.1. FRAME
1.2. SUBPLOT
2. PLOTTING
2.1. Data
2.3. Imshow
'for t in plt.legend().get_texts():
t.set_color('white')'
2.4. Histograms
We can plot points in the 2D space but with the feature that we can
choose the size of the marker to be dependent on the position of the grid. We use
'plt.scatter(x,y,s=)'. 's' is the array of the same shape of the data that has the
size for the markers. We can also use the colorbar as it was done in the Imshow,
only putting the label as the argument. To create the color in the plot, we use the
kwarg 'c=,cmap=' where c is the values and cmap the color map used.
We use 'plt.errorbar(x,y,yerr=,xerr=,...)'.
3. 3D PLOTS
4. MESHGRID
'''
nx, ny = (3, 2)
x = np.linspace(0, 1, nx) # 3 points for the x axis
y = np.linspace(0, 1, ny) # 2 points for the y axis
xv, yv = np.meshgrid(x, y)
xv # x coordinates of all the points according to the combination of
both x and y points
array([[0. , 0.5, 1. ],
[0. , 0.5, 1. ]])
yv # y coordinates
array([[0., 0., 0.],
[1., 1., 1.]])
'''
The total number of points is 6 in this example and this result is called
coordinate grid. We can print it with using plt.plot(xv,yv) in a normal way. We can
'.ravel()' the two arrays of coordinates and 'zip' them to obtain all the different
points.
ax = fig.gca(projection='3d')
ax.plot_surface(xv, yv, z)
In the example from the second lecture he uses the meshgrid to create an
image of the parameter space with the color representing the value they have
associated in the loss function.