I'm using jupyter notebook. If it's not a jupyter notebook, you don't need "% matplotlib inline"
#Library import
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
#Function you want to draw a graph
def func(x):
return x**2
#Variable preparation
# np.arange(start,End,Step)
x = np.arange(0.0, 10.0, 0.1)
y = func(x)
#Draw on graph
plt.plot(x, y);
#Library import
%matplotlib inline
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
#Function you want to draw a graph
def func(x, y):
return x * y * (10 - x - y)
#Variable preparation
x = np.arange(0.0, 10.0, 0.1)
y = np.arange(0.0, 10.0, 0.1)
X, Y = np.meshgrid(x, y)
Z = func(X, Y)
#drawing
fig = plt.figure()
ax = Axes3D(fig)
ax.set_xlabel("x")
ax.set_ylabel("y")
ax.set_zlabel("f(x, y)")
ax.plot_wireframe(X, Y, Z)
plt.show()
Recommended Posts