如何在三维绘图中标记点?Matplotlib | Mpl|u工具库

2024-09-29 03:27:26 发布

您现在位置:Python中文网/ 问答频道 /正文

python新手,我已经在论坛上搜索了一个答案,但是我似乎没有找到一个明确的解决方案。你知道吗

我的矩阵如下所示:

Country | Agri   | Manu | Serv | 
AFG     | 0.7    | 0.1  |  0.3 |
ALB     | 0.2    | 0.5  |  0.4 |
BEL     | 0.1    | 0.8  |  0.1 |

我想按国家(列0)标记每个数据点。我该怎么做?你知道吗

我的代码:

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

fig = plt.figure(figsize=(10,8))
ax=fig.add_subplot(111,projection='3d')

ax.scatter(orig_df['Agri'],
        orig_df['Manu'],
         orig_df['Serv'],
        marker='o',
        color='b',
        alpha=0.7,
        s = 124)

ax.set_title('Three Sector Economy')
ax.set_xlabel('Agriculture')
ax.set_xlim([0,1])
ax.set_ylabel('Manufacturing')
ax.set_ylim([0,1])
ax.set_zlabel('Services')
ax.set_zlim([0,1])

plt.show()

我的输出: 3D pic


Tags: 答案importdffigplt矩阵解决方案ax