---
# System prepended metadata

title: Python Matplotlib Draw 3D
tags: [Python, ' Matplotlib']

---

---
tags: Python, Matplotlib
---

# Python Matplotlib Draw 3D

[![hackmd-github-sync-badge](https://hackmd.io/-uRCAG_cTue_c8kn5XVm_A/badge)](https://hackmd.io/-uRCAG_cTue_c8kn5XVm_A)


```python
# need to import
from mpl_toolkits.mplot3d.axes3d import Axes3D
```


### Single plot 3D
```python
fig = plt.figure()
value = np.random.uniform(1, 15, 10240)


ax = fig.add_subplot(1, 1, 1, projection='3d')

color_map = plt.cm.get_cmap()
map = ax.scatter(R, G, B, c=value, cmap=color_map)
fig.colorbar(map, ax=ax)
plt.show()
```

### multi plot 3D
```python
fig = plt.figure()
value = np.random.uniform(1, 15, 10240)

ax = fig.add_subplot(1, 2, 1, projection='3d')

color_map = plt.cm.get_cmap()
map = ax.scatter(R, G, B, c=value, cmap=color_map)
fig.colorbar(map, ax=ax)

ax = fig.add_subplot(1, 2, 2, projection='3d')
color_map = plt.cm.get_cmap()
map = ax.scatter(sR, sG, sB, c=value, cmap=color_map)
fig.colorbar(map, ax=ax)

plt.show()
```