Just a fun program to see how to execute some python code
To run all of the cells at once, click on the 'Cell' menu and then 'Run all'.
To run one cell at a time, click on that cell and then hold down 'shift' while pressing 'enter'. Note that you should run the cells in order!
In [ ]:
%matplotlib inline
In [ ]:
import matplotlib.pyplot as plt
from PIL import Image
import requests
import numpy
from io import BytesIO
In [ ]:
url='http://brand.msu.edu/_files/images/logo-helmet-black.png'
response = requests.get(url)
img = Image.open(BytesIO(response.content))
In [ ]:
img
In [ ]:
img_array = numpy.array(img);
img_array
In [ ]:
img_array.shape
Example from: http://matplotlib.org/mpl_toolkits/mplot3d/tutorial.html
In [ ]:
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
from matplotlib.ticker import LinearLocator, FormatStrFormatter
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
ax = fig.gca(projection='3d')
X = np.arange(-5, 5, 0.25)
Y = np.arange(-5, 5, 0.25)
X, Y = np.meshgrid(X, Y)
R = np.sqrt(X**2 + Y**2)
Z = np.sin(R)
surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.coolwarm,
linewidth=0, antialiased=False)
ax.set_zlim(-1.01, 1.01)
ax.zaxis.set_major_locator(LinearLocator(10))
ax.zaxis.set_major_formatter(FormatStrFormatter('%.02f'))
fig.colorbar(surf, shrink=0.5, aspect=5)
plt.show()
In [ ]: