首页 > 解决方案 > 在 matplotlib 3D scatter 中将一点放在前面

问题描述

我试图在下面的情节中把明星带到前面。我试过zorder了,但它不起作用。你有什么建议吗?

from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt

fig = plt.figure(figsize=(12,6))

ax = fig.gca(projection='3d')
ax.zaxis.get_major_formatter().set_useOffset(True)
#ax.zaxis.set_rotate_label(False)
#ax.yaxis.set_rotate_label(False)
#ax.xaxis.set_rotate_label(False)

ax.scatter(optim_index[np.argmin(optim_val)][0], optim_index[np.argmin(optim_val)][1], min(optim_val),
           marker = '*', color = 'green', s=100, zorder=10, label = 'Optimal Solution')
ax.scatter(Plist, Vlist, Objlist, marker = '.', color = 'grey',label='Infeasible Solution')
ax.scatter(Feas_P, Feas_V, Objval, marker = '.', color = 'royalblue', label='Feasible Solution')


ax.view_init(30, 40)
ax.set_xlabel('Laser Power (W)', rotation = 6)
ax.set_ylabel('Scan Speed (mm/s)', rotation = -30)
ax.set_zlabel('Objective Value ($)', rotation = 92)
ax.legend(loc='upper center', bbox_to_anchor=(0.7, 0.8),
          fancybox=True, shadow=False, ncol=1, scatterpoints = 1, fontsize=10)

plt.show() # Deactivate me to save the plot
#plt.savefig('ParamOptim.png', format='png') #dpi=900)  #Activate me to save the plot

在此处输入图像描述

标签: python-2.7matplotlibscatter3d

解决方案


推荐阅读