fusion-energy / openmc_regular_mesh_plotter

A Python package for plotting OpenMC regular mesh tally results with underlying geometry from neutronics simulations.
MIT License
10 stars 1 forks source link

add plotly option #63

Open shimwell opened 11 months ago

shimwell commented 11 months ago

we can do a plotly contour with this code, perhaps easy to add

import plotly.graph_objects as go

fig = go.Figure(data =
    go.Contour(
        z=[[10, 10.625, 12.5, 15.625, 20],
           [5.625, 6.25, 8.125, 11.25, 15.625],
           [2.5, 3.125, 5., 8.125, 12.5],
           [0.625, 1.25, 3.125, 6.25, 10.625],
           [0, 0.625, 2.5, 5.625, 10]],
        x=[-9, -6, -5 , -3, -1], # horizontal axis
        y=[0, 1, 4, 5, 7] # vertical axis
    ))
fig.show()
shimwell commented 11 months ago

slightly improved


    import plotly.graph_objects as go

    dx = abs(x_min - x_max)/(data.shape[0]-1)
    dy = abs(y_min - y_max)/(data.shape[1]-1)

    fig = go.Figure(data =
        go.Contour(
            z=data,
            x0=x_min,
            dx=dx,
            y0=y_min,
            dy=dy,
            showscale=colorbar
            label
        ))
    fig.show()
shimwell commented 8 months ago

some useful code in the openmc_plot app https://github.com/fusion-energy/openmc_plot/blob/ea15db4c667c8c5a0f8819c51ffaeedb1fbf35be/src/openmc_plot/pages/2_%F0%9F%A7%8A_Regular_mesh_plot.py