# A question about scatter plot in Plots.jl

**URL:** <https://discourse.julialang.org/t/a-question-about-scatter-plot-in-plots-jl/50638>\
**Category:** Visualization\
**Created:** [November 23, 2020, 3:47pm UTC](https://discourse.julialang.org/t/a-question-about-scatter-plot-in-plots-jl/50638 "2020-11-23T15:47:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![O\_Julia](https://avatars.discourse-cdn.com/v4/letter/o/3ab097/32.png) [@O\_Julia](https://discourse.julialang.org/u/O_Julia)\
**Post date:** [November 23, 2020, 3:47pm UTC](https://discourse.julialang.org/t/a-question-about-scatter-plot-in-plots-jl/50638/1 "2020-11-23T15:47:19Z")

</div>

I have three variables as coordinates in space and a fourth variable being color. I want to assign each color to each point in space. In python this can be done as follows:

```julia
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
from numpy import random

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

x = random.rand(50)
y = random.rand(50)
z = random.rand(50)
c = random.rand(50)

s = ax.scatter(x, y, z, c=c, cmap=plt.viridis())
fig.colorbar(s)
plt.show()

```

How can I reproduce same results in Julia using plotly() from Plots.jl?

---

<div class="post-metadata">

**Author:** ![BeastyBlacksmith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/beastyblacksmith/32/4741_2.png) [@BeastyBlacksmith](https://discourse.julialang.org/u/BeastyBlacksmith)\
**Post date:** [November 23, 2020, 8:28pm UTC](https://discourse.julialang.org/t/a-question-about-scatter-plot-in-plots-jl/50638/2 "2020-11-23T20:28:32Z")

</div>

```julia
using Plots
plotly()
x = rand(50); y = rand(50); z = rand(50); c = rand(50);

scatter(x, y, z, marker_z = c)
```

---

<div class="post-metadata">

**Author:** ![O\_Julia](https://avatars.discourse-cdn.com/v4/letter/o/3ab097/32.png) [@O\_Julia](https://discourse.julialang.org/u/O_Julia)\
**Post date:** [November 24, 2020, 11:02am UTC](https://discourse.julialang.org/t/a-question-about-scatter-plot-in-plots-jl/50638/3 "2020-11-24T11:02:37Z")

</div>

Thank you, this works.
