Last active
July 5, 2020 13:42
-
-
Save mithi/e73fba3fca21c364be1229782280c3fa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from mpl_toolkits.mplot3d import axes3d | |
import matplotlib.pyplot as plt | |
import numpy as np | |
%matplotlib inline | |
fig = plt.figure(figsize=(18, 16), dpi= 80) | |
ax = plt.axes(projection='3d') | |
ax.set_xlim3d(-100, 100) | |
ax.set_ylim3d(-100, 100) | |
ax.set_zlim3d(-100, 100) | |
# Data for a three-dimensional line | |
z = np.linspace(-75, 75, 500) | |
x = 50 * np.sin(z) | |
y = 50 * np.cos(z) | |
ax.plot3D(x, y, z, 'red', marker = '^') | |
# Data for three-dimensional scattered points | |
zdata = 50 * np.random.random(100) | |
xdata = 50 * np.sin(zdata) + 100 * np.random.randn(100) | |
ydata = 50 * np.cos(zdata) + 100 * np.random.randn(100) | |
ax.scatter3D(xdata, ydata, zdata, s = 300); | |
angle = 100 | |
ax.view_init(30, angle) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from mpl_toolkits.mplot3d import axes3d | |
import matplotlib.pyplot as plt | |
import numpy as np | |
%matplotlib inline | |
def draw_plot(scatter_data, line_data): | |
angle = 30 | |
fig = plt.figure(figsize=(18, 16), dpi= 80) | |
ax = plt.axes(projection='3d') | |
ax.view_init(30, angle) | |
ax.set_xlim3d(-100, 100) | |
ax.set_ylim3d(-100, 100) | |
ax.set_zlim3d(-100, 100) | |
ax.plot3D( | |
line_data["x"], | |
line_data["y"], | |
line_data["z"], | |
'red', | |
marker = '^' | |
) | |
ax.scatter3D( | |
scatter_data["x"], | |
scatter_data["y"], | |
scatter_data["z"], | |
s = 300 | |
) | |
# Data for a three-dimensional line | |
z = np.linspace(-75, 75, 500) | |
x = 50 * np.sin(z) | |
y = 50 * np.cos(z) | |
line_data = {"x": x, "y": y, "z": z} | |
# Data for three-dimensional scattered points | |
zdata = 50 * np.random.random(100) | |
xdata = 50 * np.sin(zdata) + 100 * np.random.randn(100) | |
ydata = 50 * np.cos(zdata) + 100 * np.random.randn(100) | |
scatter_data = {"x": xdata, "y": ydata, "z": zdata} | |
draw_plot(scatter_data, line_data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment