Closed gooyle closed 1 year ago
Another codes has been tried, though its still not good enough.
import matplotlib.pyplot as plt with plt.style.context(['science', "ieee", 'std-colors']): fig, axes = plt.subplots(figsize = (20,4), subplot_kw=dict(projection= '3d')) axes.xaxis.pane.fill = False axes.yaxis.pane.fill = False axes.zaxis.pane.fill = False axes.grid(False) axes.scatter(X_new[mask,0], X_new[mask,1], X_new[mask,2], c = 'b', s = 5, depthshade = False, linewidth = 0.2, edgecolors='k')`
From the matplotlib example library, I've used this one.
I've only added two lines, the import scienceplots
and plt.style.use(...)
, and styles seem to apply without problems. Next time, pls provide a reproducible example.
import matplotlib.pyplot as plt
import numpy as np
import scienceplots
plt.style.use(['science', "ieee", 'std-colors'])
# Fixing random state for reproducibility
np.random.seed(19680801)
def randrange(n, vmin, vmax):
"""
Helper function to make an array of random numbers having shape (n, )
with each number distributed Uniform(vmin, vmax).
"""
return (vmax - vmin)*np.random.rand(n) + vmin
fig = plt.figure()
ax = fig.add_subplot(projection='3d')
n = 100
# For each set of style and range settings, plot n random points in the box
# defined by x in [23, 32], y in [0, 100], z in [zlow, zhigh].
for m, zlow, zhigh in [('o', -50, -25), ('^', -30, -5)]:
xs = randrange(n, 23, 32)
ys = randrange(n, 0, 100)
zs = randrange(n, zlow, zhigh)
ax.scatter(xs, ys, zs, marker=m)
ax.set_xlabel('X Label')
ax.set_ylabel('Y Label')
ax.set_zlabel('Z Label')
plt.show()
thx for your reply, we will try this example
From the matplotlib example library, I've used this one.
I've only added two lines, the
import scienceplots
andplt.style.use(...)
, and styles seem to apply without problems. Next time, pls provide a reproducible example.import matplotlib.pyplot as plt import numpy as np import scienceplots plt.style.use(['science', "ieee", 'std-colors']) # Fixing random state for reproducibility np.random.seed(19680801) def randrange(n, vmin, vmax): """ Helper function to make an array of random numbers having shape (n, ) with each number distributed Uniform(vmin, vmax). """ return (vmax - vmin)*np.random.rand(n) + vmin fig = plt.figure() ax = fig.add_subplot(projection='3d') n = 100 # For each set of style and range settings, plot n random points in the box # defined by x in [23, 32], y in [0, 100], z in [zlow, zhigh]. for m, zlow, zhigh in [('o', -50, -25), ('^', -30, -5)]: xs = randrange(n, 23, 32) ys = randrange(n, 0, 100) zs = randrange(n, zlow, zhigh) ax.scatter(xs, ys, zs, marker=m) ax.set_xlabel('X Label') ax.set_ylabel('Y Label') ax.set_zlabel('Z Label') plt.show()
hi, is there any examples for 3d plot, we try module
mpl_toolkits.mplot3d
, however, it doesnot works well withscienceplot