Not a question, but a 3D PlotlyJS gallery

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.

Code and more 3D charts at the link above!

27 Likes

Nice!

Thank you!

love this – great work

1 Like

@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.

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.

@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.

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.

@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.

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:

begin
	using PlotlyBase
	using HypertextLiteral
	using Colors # I am not sure Colors is doing anything in the plot
	#using ColorSchemes
end
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