Fixat så att graferna ritas tillsammans i en gemensam ram
This commit is contained in:
+2
-7
@@ -9,14 +9,12 @@ def plot_surface(ax):
|
||||
X, Y = np.meshgrid(x, y)
|
||||
Z = (np.sin(X**2 + Y**2)) / (X**2 + Y**2)
|
||||
|
||||
fig = plt.figure()
|
||||
ax = fig.add_subplot(111, projection='3d')
|
||||
ax.plot_surface(X, Y, Z, cmap='viridis', edgecolor='none')
|
||||
ax.set_xlabel('X')
|
||||
ax.set_ylabel('Y')
|
||||
ax.set_zlabel('Z')
|
||||
ax.set_title(r'$Z = \frac{\sin(X^2 + Y^2)}{X^2 + Y^2}$')
|
||||
plt.show()
|
||||
|
||||
|
||||
# Function to plot the Klein bottle using parametric equations
|
||||
def plot_klein_bottle(ax):
|
||||
@@ -27,9 +25,7 @@ def plot_klein_bottle(ax):
|
||||
x = np.sin(V) * (np.cos(T) + 2)
|
||||
y = np.cos(V) * (np.cos(T) + 2)
|
||||
z = np.sin(T) * np.cos(V)
|
||||
|
||||
fig = plt.figure()
|
||||
ax = fig.add_subplot(111, projection='3d')
|
||||
|
||||
|
||||
# Plot the surface with color and smoothing parameters
|
||||
ax.plot_surface(x, y, z, color='b', rstride=4, cstride=4) # Adjust rstride and cstride for smoother or more detailed surface
|
||||
@@ -38,7 +34,6 @@ def plot_klein_bottle(ax):
|
||||
ax.set_zlim([-1, 1])
|
||||
ax.set_title('Klein Bottle')
|
||||
|
||||
plt.show()
|
||||
|
||||
# Main function to call the plotting functions
|
||||
def main():
|
||||
|
||||
Reference in New Issue
Block a user