Black Lives Matter. Please consider donating to Black Girls Code today.
Dash HoloViews is now available! Check out the docs.

How do I show the marker colorscale on the side o

I want to create a Scatter3d plot and use the marker colorscale for conveying information. It’s all good, the only catch is how do I show the colorscale on my plot?

def get_Scatter_plot(dframe):
    #these strings e.g. x-coor , x-disp are coming from the dumped csv file
    #which in turn is coming from the DYNA nodout file
    xt="x-coor"
    yt="y-coor"
    zt="z-coor"
    abs_disp=(dframe['x-disp']**2+dframe['y-disp']**2+dframe['z-disp']**2)**(0.5)
    axis_range=set_axis_ranges(dframe)
    trace=Scatter3d(x=dframe[xt].values,y=dframe[yt].values,z=dframe[zt].values,
    mode='markers',
    marker=dict(size=3,color=abs_disp,colorscale='Jet'),
    legendgroup=abs_disp,
    hovertext=abs_disp)
    data=[trace]
    layout=Layout(scene=dict(xaxis=dict(range=axis_range[xt]),
    yaxis=dict(range=axis_range[yt]),
    zaxis=dict(range=axis_range[zt])),
    margin=dict(l=0,r=0,b=0,t=0))
    fig=Figure(data=data,layout=layout)
    return fig

Here is what I get by passing my data to this function:

Ok, it looks like I was a little impatient to post this, so for future reference you only need to pass showscale=True in the marker dictionary, it doesn’t work if you pass it as an attribute of the Scatter3d itself, which was what I was doing before.
Here is the code with the modification:

def get_Scatter_plot(dframe):
    #these strings e.g. x-coor , x-disp are coming from the dumped csv file
    #which in turn is coming from the DYNA nodout file
    xt="x-coor"
    yt="y-coor"
    zt="z-coor"
    abs_disp=(dframe['x-disp']**2+dframe['y-disp']**2+dframe['z-disp']**2)**(0.5)
    axis_range=set_axis_ranges(dframe)
    trace=Scatter3d(x=dframe[xt].values,y=dframe[yt].values,z=dframe[zt].values,
    mode='markers',
    marker=dict(size=3,color=abs_disp,colorscale='Jet',showscale=True),
    legendgroup=abs_disp,
    hovertext=abs_disp)
    data=[trace]
    layout=Layout(scene=dict(xaxis=dict(range=axis_range[xt]),
    yaxis=dict(range=axis_range[yt]),
    zaxis=dict(range=axis_range[zt])),
    margin=dict(l=0,r=0,b=0,t=0))
    fig=Figure(data=data,layout=layout)
    return fig

and the result: