def DrawDigit(A, label=''): """ Draw single digit as a greyscale matrix""" fig = plt.figure(figsize=(6, 6)) # Uso la colormap 'gray' per avere la schacchiera in bianco&nero img = plt.imshow(A, cmap='gray_r') plt.xlabel(label) plt.show()
addComputationIndex=True, useMultiProcessing=True, showProgress=True, ) print("--- %s seconds ---" % (time.time() - start_time)) from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import import matplotlib.pyplot as plt #from matplotlib import cm #from matplotlib.ticker import LinearLocator, FormatStrFormatter import numpy as np colorMap = plt.cm.get_cmap('jet') #finite element colors plt.close('all') fig = plt.figure() ax = fig.gca(projection='3d') #reshape output of parametervariation to fit plot_surface X = np.array(pDict['mass']).reshape((n,n)) Y = np.array(pDict['spring']).reshape((n,n)) Z = np.array(values).reshape((n,n)) surf = ax.plot_surface(X, Y, Z, cmap=colorMap, linewidth=2, antialiased=True, shade = True) plt.colorbar(surf, shrink=0.5, aspect=5) plt.tight_layout() #++++++++++++++++++++++++++++++++++++++++++++++++++
] # Instantiate a Gaussian Process model gp = GaussianProcessRegressor(kernel=kernel, alpha=dy**2, n_restarts_optimizer=10) # Fit to data using Maximum Likelihood Estimation of the parameters gp.fit(X, y) # Make the prediction on the meshed x-axis (ask for MSE as well) y_pred, sigma = gp.predict(x, return_std=True) # Plot the function, the prediction and the 95% confidence interval based on # the MSE plt.figure() plt.errorbar(X.ravel(), y, dy, fmt='r.', markersize=10, label=u'Observations') plt.plot(x, y_pred, 'b-', label=u'Prediction') plt.fill(np.concatenate([x, x[::-1]]), np.concatenate( [y_pred - 1.9600 * sigma, (y_pred + 1.9600 * sigma)[::-1]]), alpha=.5, fc='b', ec='None', label='95% confidence interval') plt.xlabel('$x$') plt.ylabel('$f(x)$') plt.ylim(-10, 20) plt.legend(loc='upper left') plt.show()
from mpl_toolkits.mplot3d import axes3d import matplotlib.plt as plt import numpy as np fig = plt.figure(5) ax = fig.gca(projection='3d') # axes range ax.set_xlim3d(-1, 1) ax.set_ylim3d(-1, 1) ax.set_zlim3d(-1, 1) # axes labels ax.set_xlabel('x') ax.set_ylabel('y') ax.set_zlabel('z') # normalizing a matrix def normalize(A): return A / np.linalg.norm(A) # the vectors from the diagram V = -normalize(np.array([1.0**0.5, 0.0**0.5, -1.0**0.5])) L = np.array([0.5**0.5, 0.5**0.5, 0.0**0.5]) N = np.array([0.0**0.5, 0.5**0.5, 0.0**0.5]) R = np.array([-0.5**0.5, 0.0**0.5, 0.5**0.5]) #R = normalize(2*np.dot(N,L)*N-L) vectors = [