# PlotlyJS Heatmap change colors to grayscale

**URL:** https://discourse.julialang.org/t/plotlyjs-heatmap-change-colors-to-grayscale/89973
**Category:** New to Julia
**Tags:** plotting, colors, plotlyjs
**Created:** [November 9, 2022, 11:02am UTC](https://discourse.julialang.org/t/plotlyjs-heatmap-change-colors-to-grayscale/89973 "2022-11-09T11:02:24Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![JorizovdZ](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jorizovdz/32/43064_2.png) [@JorizovdZ](https://discourse.julialang.org/u/JorizovdZ)
#### Post date: [November 9, 2022, 11:02am UTC](https://discourse.julialang.org/t/plotlyjs-heatmap-change-colors-to-grayscale/89973/1 "2022-11-09T11:02:24Z")

</div>

I want to transform my thermal heatmap to grayscale. I tried different options and arguments, though it keeps returning the standard color format. I’m using the packages below with versions and ran the attached code below to test it on random.

```julia
using PlotlyJS, Plots, Distributions, Statistics, ColorSchemes
test_x=vec(collect(1:2:30))
test_y=vec(collect(1:10))
rand_test = Matrix(rand(10, 15))
PlotlyJS.plot(PlotlyJS.heatmap(x=test_x, y=test_y, z=rand_test, seriescolor=cgrad(:grayC)))

# Though just the cgrad for :grayC or :greys shows the right seriescolor
cgrad(:grayC)
cgrad(:greys)

```

This gives the following heatmap:

 ![Heatmap_test](https://global.discourse-cdn.com/julialang/original/3X/1/b/1b274faa255c1ee4299238d4ba61816bda8a4af1.png)

Julia Version 1.7.1  
Commit ac5cc99908 (2021-12-22 19:35 UTC)  
Platform Info:  
OS: Windows (x86\_64-w64-mingw32)  
CPU: Intel(R) Core™ i7-7700HQ CPU @ 2.80GHz

Package versions  
[f0f68f2c] PlotlyJS v0.18.10  
[91a5bcdd] Plots v1.36.0  
[31c24e10] Distributions v0.25.77  
[10745b16] Statistics  
[35d6a980] ColorSchemes v3.19.0

---

<div class="post-metadata">

### Author: ![VivMendes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vivmendes/32/16477_2.png) [@VivMendes](https://discourse.julialang.org/u/VivMendes)
#### Post date: [November 9, 2022, 1:26pm UTC](https://discourse.julialang.org/t/plotlyjs-heatmap-change-colors-to-grayscale/89973/2 "2022-11-09T13:26:56Z")

</div>

Hi,

Firstly, PlotlyJS and Plots are two alternative plotting packages. You could use one or the other, not the two together. Or you may choose to use Plots, and choose the plotlyjs() backend.

Your code works without problem if you choose a built-in color scale from Plotly [here](https://plotly.com/python/builtin-colorscales/). Your code

```julia
using PlotlyJS
test_x=vec(collect(1:2:30))
test_y=vec(collect(1:10))
rand_test = Matrix(rand(10, 15))
plot(heatmap(x=test_x, y=test_y, z=rand_test, colorscale = "Greys"))

```

and the heatmap I think you are looking for:

 ![aa](https://global.discourse-cdn.com/julialang/original/3X/e/b/ebdb618657a89ff0ab22402ab40c42a2902afd5a.png)

---

<div class="post-metadata">

### Author: ![JorizovdZ](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jorizovdz/32/43064_2.png) [@JorizovdZ](https://discourse.julialang.org/u/JorizovdZ)
#### Post date: [November 9, 2022, 2:39pm UTC](https://discourse.julialang.org/t/plotlyjs-heatmap-change-colors-to-grayscale/89973/3 "2022-11-09T14:39:11Z")

</div>

> [@VivMendes](#):
>
> PlotlyJS and Plots are two alternative plotting packages. You could use one or the other, not the two together. Or you may choose to use Plots, and choose the plotlyjs() backend

Yes, I know. I used both as I was using the `Plots` package for my scatters and bar plots, whereas I used `PlotlyJS` for the `heatmap()`. So I will delete one and use the backend.

> [@VivMendes](#):
>
> choose a built-in color scale from Plotly

Thank you, that is probably the reason it didn’t work properly. Though, it should also possible to chose different color scales (From the `ColorSchemes` package) .

---

<div class="post-metadata">

### Author: ![jd-foster](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jd-foster/32/35824_2.png) [@jd-foster](https://discourse.julialang.org/u/jd-foster)
#### Post date: [November 10, 2022, 12:23am UTC](https://discourse.julialang.org/t/plotlyjs-heatmap-change-colors-to-grayscale/89973/4 "2022-11-10T00:23:23Z")

</div>

Does this do what your want?

```julia
import PlotlyJS
const CS = PlotlyJS.PlotlyBase.ColorSchemes

test_x=vec(collect(1:2:30))
test_y=vec(collect(1:10))
rand_test = Matrix(rand(10, 15))

p = PlotlyJS.heatmap(x=test_x, y=test_y, z=rand_test, colorscale = CS.grayC)
PlotlyJS.plot(p)

q = PlotlyJS.heatmap(x=test_x, y=test_y, z=rand_test, colorscale = CS.grays)
PlotlyJS.plot(q)

```

---

<div class="post-metadata">

### Author: ![JorizovdZ](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jorizovdz/32/43064_2.png) [@JorizovdZ](https://discourse.julialang.org/u/JorizovdZ)
#### Post date: [November 10, 2022, 8:20am UTC](https://discourse.julialang.org/t/plotlyjs-heatmap-change-colors-to-grayscale/89973/5 "2022-11-10T08:20:30Z")

</div>

Yes @jd-foster, thank you very much for showing this!
