# Not a question, but a 3D PlotlyJS gallery

**URL:** <https://discourse.julialang.org/t/not-a-question-but-a-3d-plotlyjs-gallery/65063>\
**Category:** Visualization\
**Tags:** plotlyjs\
**Created:** [July 21, 2021, 7:23pm UTC](https://discourse.julialang.org/t/not-a-question-but-a-3d-plotlyjs-gallery/65063 "2021-07-21T19:23:33Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![empet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/empet/32/221303_2.png) [@empet](https://discourse.julialang.org/u/empet)\
**Post date:** [July 21, 2021, 7:23pm UTC](https://discourse.julialang.org/t/not-a-question-but-a-3d-plotlyjs-gallery/65063/1 "2021-07-21T19:23:33Z")

</div>

I’m a Julia beginner, as you may have noticed from the basic questions I have asked here.  
To practice it I created a small project and gallery of 3D PlotlyJS charts, here:  
[https://github.com/empet/3D-Viz-with-PlotlyJS.jl](https://github.com/empet/3D-Viz-with-PlotlyJS.jl).

 ![thumbnails1](https://global.discourse-cdn.com/julialang/original/3X/a/a/aafdbbbfb635bbdc97dfad5b5ecddbefb2f366aa.jpeg)

Code and more 3D charts at the link above!

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [July 21, 2021, 7:46pm UTC](https://discourse.julialang.org/t/not-a-question-but-a-3d-plotlyjs-gallery/65063/2 "2021-07-21T19:46:26Z")

</div>

Nice!

---

<div class="post-metadata">

**Author:** ![empet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/empet/32/221303_2.png) [@empet](https://discourse.julialang.org/u/empet)\
**Post date:** [July 22, 2021, 9:02am UTC](https://discourse.julialang.org/t/not-a-question-but-a-3d-plotlyjs-gallery/65063/3 "2021-07-22T09:02:09Z")

</div>

Thank you!

---

<div class="post-metadata">

**Author:** ![sglyon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sglyon/32/67_2.png) [@sglyon](https://discourse.julialang.org/u/sglyon)\
**Post date:** [July 30, 2021, 7:34pm UTC](https://discourse.julialang.org/t/not-a-question-but-a-3d-plotlyjs-gallery/65063/4 "2021-07-30T19:34:35Z")

</div>

love this – great work

---

<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:** [October 15, 2021, 9:50pm UTC](https://discourse.julialang.org/t/not-a-question-but-a-3d-plotlyjs-gallery/65063/5 "2021-10-15T21:50:10Z")

</div>

@empet, fantastic stuff, pure beauty on a computer. I have just become aware of your gallery and have a stupid question: is it possible to implement them in Pluto? As far as I know, Pluto does not allow to `include` Julia files. If there is a turnaround to this problem, I would be delighted to know because I am kind of desperate to use the code in your first notebook. Congrats.

---

<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:** [October 16, 2021, 2:28am UTC](https://discourse.julialang.org/t/not-a-question-but-a-3d-plotlyjs-gallery/65063/6 "2021-10-16T02:28:03Z")

</div>

To replicate your first notebook was easy, but the colors I came up with are not nice. I will have to see how to improve on that part.

---

<div class="post-metadata">

**Author:** ![empet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/empet/32/221303_2.png) [@empet](https://discourse.julialang.org/u/empet)\
**Post date:** [October 16, 2021, 9:49am UTC](https://discourse.julialang.org/t/not-a-question-but-a-3d-plotlyjs-gallery/65063/7 "2021-10-16T09:49:33Z")

</div>

@VivMendes You can avoid including those files. I used PlotlyJS v 018.0, but starting with v \>0.18.5(?!) the style is no more available. Instead you can use the plotly templates.  
To get the colorscheme involved in a plot, check its name and either generate it with the function `plotly_cs()` from `src/PlotlyColorSchemes.jl` or use the latest way to load a colorscheme.

 ![colorscale](https://global.discourse-cdn.com/julialang/original/3X/1/3/13d4df25b30621d69f11c69113aa927c09b098f3.png)

Unfortunately the actual implementation of loading a colorscheme, as `colors.colorschemeName`, overloads the json file of the plot, because it uses all 256 colors (or even 512, in the case of cmocean diverging colorschemes). That’s why I prefer to generate the plotly version consisting in 11 or 21 colors and paste it in the code. In this case plotly.js will interpolate the rgb colors for any normalized data value. To get the reversed colorscheme, just add `reversescale=true` to the trace definition.

---

<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:** [October 16, 2021, 11:20am UTC](https://discourse.julialang.org/t/not-a-question-but-a-3d-plotlyjs-gallery/65063/8 "2021-10-16T11:20:00Z")

</div>

@empet, thank you very much for your help.

In Pluto, I will have to use `PlotlyBase.jl` instead of `PlotlyJS.jl` to render the plots (to save plots I use: `import Plotly:savefig`). This turnaround was possible due to a terrific contribution by @disberd  
[here](https://discourse.julialang.org/t/pluto-plots-with-plotlybase-plotlyjs-with-working-static-html-export/61730/9).

A couple of months ago, I played with colors in some 2D and 3D plots using PlotlyJS. I have just checked and came up with this version of your 3D fantastic plot. It looks better now, but how can I get rid of the **sandy** view of the projection of the contour curves on its basis?

**Edited** : I am on a Windows 10 machine, using Julia 1.6.3, PlotlyJS.jl v0.18.8, PlotlyBase v0.0.18, and Pluto v0.16.1.

Please see my efforts below, where I marginally changed your code:

```julia
begin
	using PlotlyBase
	using HypertextLiteral
	using Colors # I am not sure Colors is doing anything in the plot
	#using ColorSchemes
end

```

```julia
begin
	surf = surface(x=x, y=y, z=z, 
               colorscale="pl_algae", 
			   #colorscale = "Jet",
               colorbar_len=0.7,
               contours_z=attr(show=true, start=minimum(z), 
                               size=0.4, width= 2, color="rgb(200,200,200)", 
                               usecolormap=false, project_z=true),
               contours_z_end=maximum(z)) 

	proj = surface(x=x, y=y, 
				   z=-5*ones(size(z)), #h=-5
				   surfacecolor=z, 
				   #colorscale = "Hot",
				   colorscale="pl_algae",
				   showscale=false)          

	layout = Layout(width=600, height=600, 
					scene = attr(camera_eye=attr(x=-1.65, y= 1.65, z=0.75),
								 xaxis=merge(ax_commons, attr(showgrid=false)),
								 yaxis=merge(ax_commons, attr(showgrid=false)),
								 zaxis=merge(ax_commons,
											 attr(gridcolor="white",
												  gridwidth = 2,
												  range=[-5, maximum(z)+0.5]))))     
	pl = Plot([surf, proj], layout)
end

```

 ![aaa](https://global.discourse-cdn.com/julialang/original/3X/2/2/2273ed3857a66b930cd4a56e74f64660b2cd022b.jpeg)
