-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathastro_plots.py
More file actions
23 lines (18 loc) · 786 Bytes
/
astro_plots.py
File metadata and controls
23 lines (18 loc) · 786 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import numpy as np
import matplotlib.pyplot as plt
def create_3d_plot(size, max_distance):
# Calculate the spacing between points in the matrix
spacing = max_distance * 2 / (size - 1)
# Create a meshgrid of x, y, and z values
x_vals = np.linspace(-max_distance, max_distance, size)
y_vals = np.linspace(-max_distance, max_distance, size)
z_vals = np.linspace(-max_distance, max_distance, size)
x, y, z = np.meshgrid(x_vals, y_vals, z_vals, indexing='ij')
# Create the 3D plot
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
# Set the limits of the plot
ax.set_xlim(-max_distance, max_distance)
ax.set_ylim(-max_distance, max_distance)
ax.set_zlim(-max_distance, max_distance)
return ax