# Plot marker colors to match the data values

**URL:** <https://discourse.julialang.org/t/plot-marker-colors-to-match-the-data-values/74367>\
**Category:** New to Julia\
**Tags:** question, plotting\
**Created:** [January 10, 2022, 11:11pm UTC](https://discourse.julialang.org/t/plot-marker-colors-to-match-the-data-values/74367 "2022-01-10T23:11:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kubouch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kubouch/32/31194_2.png) [@kubouch](https://discourse.julialang.org/u/kubouch)\
**Post date:** [January 10, 2022, 11:11pm UTC](https://discourse.julialang.org/t/plot-marker-colors-to-match-the-data-values/74367/1 "2022-01-10T23:11:09Z")

</div>

Hi, I’m still new to Julia and I have a seemingly simple task that I haven’t been able to figure out:

1. Display a group of RGB pixels as a 3D plot with r, g, b components as values on x, y, z axes (I’ve done that).
2. Select the marker colors to match the RGB pixel values (I’m struggling with this).

My code looks like this:

```julia
using Images
using Plots

# image as a 3D Array of size (num_channels, height, width)
plot_img = channelview(load("/some/image.png"))

plotly()
gui(
    scatter(
        plot_img[1, :, :],
        plot_img[2, :, :],
        plot_img[3, :, :];
        markersize=0.5,
        markerstrokewidth=0,
        markeralpha=0.5,
        legend=false,
        size=(1000, 1000),
    )
)

```

I’m using Plotly to render the 3D plot as interactive in the browser.

I found the `marker_z` option I can use when calling `scatter` which should look like `f(x, y, z) -> z_val`. However, rather than being a RGB color, the `z_val` seems to be a pointer to a palette/gradient. So I think I would need to:  
a) generate a function that maps a RGB pixel value to a 1D value  
b) generate a gradient that converts back the 1D value into the original RGB value

So yeah, I’m not really sure how to do that, or is there some more straightforward solution?

Thanks!
