Skip to content

plotly 3d surface as the surf command from Matlab #2963

@tinix84

Description

@tinix84

Hi I’m trying to obtain a plotly 3d surface as the surf command from Matlab here below

image

what I would like is to have the wireframe, the coloscale and the hover.

my input is just a CSV as with 3 columns current, voltage, energy

Any idea or help?

My actual code is:

`def plot_switching_energy_map(switching_map):

# Initialize figure with 4 3D subplots
fig = make_subplots(rows=2, cols=2, specs=[[{'type': 'scene'}, {'type': 'scene'}],[{'type': 'scene'}, {'type': 'scene'}]])

current_grid, voltage_grid = np.meshgrid(switching_map.voltage, switching_map.current)
eon_grid = interpolate.griddata((switching_map.current, switching_map.voltage), switching_map.eon, (current_grid,voltage_grid), method='cubic', fill_value=0)

Eon_surf = fig.add_trace(go.Surface(x=current_grid, y=voltage_grid, z=eon_grid, 
                colorscale='Viridis',
                name='Eon',
                showscale=True,
                ), row=1, col=1)

Eon_fig = fig.add_trace(go.Scatter3d(x=switching_map.current, y=switching_map.voltage, z=switching_map.eon, 
                mode='markers',
                name='Eon',
                marker=dict(
                    size=3,
                    color=switching_map.eoff,                # set color to an array/list of desired values
                    colorscale='Viridis',   # choose a colorscale
                    opacity=0.8
                    ),
                ), row=1, col=1)

Eoff_fig = fig.add_trace(go.Scatter3d(x=switching_map.current, y=switching_map.voltage, z=switching_map.eoff, 
                mode='markers',
                name='Eoff',
                marker=dict(
                    size=3,
                    color=switching_map.eoff,                # set color to an array/list of desired values
                    colorscale='Viridis',   # choose a colorscale
                    opacity=0.8
                    ),
                ), row=1, col=2)

# Update xaxis properties
fig.update_xaxes(title_text="current [A]", row=1, col=1)
fig.update_yaxes(title_text="voltage [V]", row=1, col=1)
# fig.update_zaxes(title_text="energy [J]", row=1, col=1)

fig.update_xaxes(title_text="current [A]", row=1, col=2)
fig.update_yaxes(title_text="voltage [V]", row=1, col=2)
# fig.update_zaxes(title_text="energy [J]", row=1, col=2)

fig.update_layout(height=1000, showlegend=True)
fig.show()

`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions