Graph plots

Use the output of roxie defined graphs and plot them using plotly

Download Input files

Setting up

Standard Loading of input, Parsing and Initializing RoxiePlotOutputs object

from roxieapi.output.plots import RoxiePlotOutputs

plots = RoxiePlotOutputs(
    "../input_files/dipole_2D_trans_opt.post.xml",
    "../input_files/dipole_2D_trans_opt.data",
)

parser = plots.output
graphs = plots.graphs

Listing all Roxie defined Graphs

Roxie defines 3 types of graphs * Device graphs (for exery time step) * Transient graphs (Time dependent data) * Optimization graphs

Shows available plots for each segment Note that device plots also list 2D plots

print("Device plots")
for pl in parser.graphs_device:
    print(f"  - {pl}")
print("Transient plots")
for pl in parser.graphs_transient:
    print(f"  - {pl}")
print("Optimization plots")
for pl in parser.graphs_optimization:
    print(f"  - {pl}")
Device plots
  - GraphPlot(title='Path plot', id=1, axes={'X': PlotAxis(label='', bounds=None, log=False), 'Y': PlotAxis(label='', bounds=None, log=False)}, graphs=[GraphInfo(id=1, graph_type=1, xval='ARCL', yval='|B|', logx=True, logy=True, weight=1.0, label=None), GraphInfo(id=4, graph_type=1, xval='ARCL', yval='BX', logx=True, logy=True, weight=1.0, label=None)])
  - GraphPlot(title='My harm coil', id=2, axes={'X': PlotAxis(label='', bounds=None, log=False), 'Y': PlotAxis(label='', bounds=None, log=False)}, graphs=[GraphInfo(id=2, graph_type=1, xval='PHI', yval='BR', logx=True, logy=True, weight=1.0, label=None), GraphInfo(id=3, graph_type=1, xval='PHI', yval='BPHI', logx=True, logy=True, weight=1.0, label=None)])
Transient plots
  - GraphPlot(title='Graph 3', id=3, axes={'X': PlotAxis(label='', bounds=None, log=False), 'Y': PlotAxis(label='', bounds=None, log=False)}, graphs=[GraphInfo(id=5, graph_type=2, xval='TIME', yval='STRONG', logx=True, logy=True, weight=1.0, label=None)])
  - GraphPlot(title='Graph 4', id=4, axes={'X': PlotAxis(label='', bounds=None, log=False), 'Y': PlotAxis(label='', bounds=None, log=False)}, graphs=[GraphInfo(id=6, graph_type=2, xval='TIME', yval='b3', logx=True, logy=True, weight=1.0, label=None)])
Optimization plots
  - GraphPlot(title='Graph 5', id=5, axes={'X': PlotAxis(label='', bounds=None, log=False), 'Y': PlotAxis(label='', bounds=None, log=False)}, graphs=[GraphInfo(id=7, graph_type=3, xval='NSTEP', yval='DV', logx=True, logy=True, weight=1.0, label=None), GraphInfo(id=8, graph_type=3, xval='NSTEP', yval='DV', logx=True, logy=True, weight=1.0, label=None), GraphInfo(id=9, graph_type=3, xval='NSTEP', yval='DV', logx=True, logy=True, weight=1.0, label=None)])

Plotting a graph

Using the Graph plotter, each graph can be output directly as a plotly graph

# Plot the first device plot graph in transient step 1, optimization step 1

plots.output_optimization_graphs(plots=[5])

# plots.output_device_graphs(1, 1, plots=[1])
{'text/html': '<div>                            <div id="3be660bc-522c-4b8c-aee7-9abf96cb6ed5" class="plotly-graph-div" style="height:800.0px; width:1200.0px;"></div>            <script type="text/javascript">                require(["plotly"], function(Plotly) {                    window.PLOTLYENV=window.PLOTLYENV || {};                                    if (document.getElementById("3be660bc-522c-4b8c-aee7-9abf96cb6ed5")) {                    Plotly.newPlot(                        "3be660bc-522c-4b8c-aee7-9abf96cb6ed5",                        [{"name":"Graph 7","x":[1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0],"y":[20.0,25.0,20.0,25.0,20.0,25.0,20.0,25.0],"type":"scatter"},{"name":"Graph 8","x":[1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0],"y":[45.0,45.0,50.0,50.0,45.0,45.0,50.0,50.0],"type":"scatter"},{"name":"Graph 9","x":[1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0],"y":[64.0,64.0,64.0,64.0,70.0,70.0,70.0,70.0],"type":"scatter"}],                        {"template":{"data":{"histogram2dcontour":[{"type":"histogram2dcontour","colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]]}],"choropleth":[{"type":"choropleth","colorbar":{"outlinewidth":0,"ticks":""}}],"histogram2d":[{"type":"histogram2d","colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]]}],"heatmap":[{"type":"heatmap","colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]]}],"heatmapgl":[{"type":"heatmapgl","colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]]}],"contourcarpet":[{"type":"contourcarpet","colorbar":{"outlinewidth":0,"ticks":""}}],"contour":[{"type":"contour","colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]]}],"surface":[{"type":"surface","colorbar":{"outlinewidth":0,"ticks":""},"colorscale":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]]}],"mesh3d":[{"type":"mesh3d","colorbar":{"outlinewidth":0,"ticks":""}}],"scatter":[{"fillpattern":{"fillmode":"overlay","size":10,"solidity":0.2},"type":"scatter"}],"parcoords":[{"type":"parcoords","line":{"colorbar":{"outlinewidth":0,"ticks":""}}}],"scatterpolargl":[{"type":"scatterpolargl","marker":{"colorbar":{"outlinewidth":0,"ticks":""}}}],"bar":[{"error_x":{"color":"#2a3f5f"},"error_y":{"color":"#2a3f5f"},"marker":{"line":{"color":"#E5ECF6","width":0.5},"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"bar"}],"scattergeo":[{"type":"scattergeo","marker":{"colorbar":{"outlinewidth":0,"ticks":""}}}],"scatterpolar":[{"type":"scatterpolar","marker":{"colorbar":{"outlinewidth":0,"ticks":""}}}],"histogram":[{"marker":{"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"histogram"}],"scattergl":[{"type":"scattergl","marker":{"colorbar":{"outlinewidth":0,"ticks":""}}}],"scatter3d":[{"type":"scatter3d","line":{"colorbar":{"outlinewidth":0,"ticks":""}},"marker":{"colorbar":{"outlinewidth":0,"ticks":""}}}],"scattermapbox":[{"type":"scattermapbox","marker":{"colorbar":{"outlinewidth":0,"ticks":""}}}],"scatterternary":[{"type":"scatterternary","marker":{"colorbar":{"outlinewidth":0,"ticks":""}}}],"scattercarpet":[{"type":"scattercarpet","marker":{"colorbar":{"outlinewidth":0,"ticks":""}}}],"carpet":[{"aaxis":{"endlinecolor":"#2a3f5f","gridcolor":"white","linecolor":"white","minorgridcolor":"white","startlinecolor":"#2a3f5f"},"baxis":{"endlinecolor":"#2a3f5f","gridcolor":"white","linecolor":"white","minorgridcolor":"white","startlinecolor":"#2a3f5f"},"type":"carpet"}],"table":[{"cells":{"fill":{"color":"#EBF0F8"},"line":{"color":"white"}},"header":{"fill":{"color":"#C8D4E3"},"line":{"color":"white"}},"type":"table"}],"barpolar":[{"marker":{"line":{"color":"#E5ECF6","width":0.5},"pattern":{"fillmode":"overlay","size":10,"solidity":0.2}},"type":"barpolar"}],"pie":[{"automargin":true,"type":"pie"}]},"layout":{"autotypenumbers":"strict","colorway":["#636efa","#EF553B","#00cc96","#ab63fa","#FFA15A","#19d3f3","#FF6692","#B6E880","#FF97FF","#FECB52"],"font":{"color":"#2a3f5f"},"hovermode":"closest","hoverlabel":{"align":"left"},"paper_bgcolor":"white","plot_bgcolor":"#E5ECF6","polar":{"bgcolor":"#E5ECF6","angularaxis":{"gridcolor":"white","linecolor":"white","ticks":""},"radialaxis":{"gridcolor":"white","linecolor":"white","ticks":""}},"ternary":{"bgcolor":"#E5ECF6","aaxis":{"gridcolor":"white","linecolor":"white","ticks":""},"baxis":{"gridcolor":"white","linecolor":"white","ticks":""},"caxis":{"gridcolor":"white","linecolor":"white","ticks":""}},"coloraxis":{"colorbar":{"outlinewidth":0,"ticks":""}},"colorscale":{"sequential":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]],"sequentialminus":[[0.0,"#0d0887"],[0.1111111111111111,"#46039f"],[0.2222222222222222,"#7201a8"],[0.3333333333333333,"#9c179e"],[0.4444444444444444,"#bd3786"],[0.5555555555555556,"#d8576b"],[0.6666666666666666,"#ed7953"],[0.7777777777777778,"#fb9f3a"],[0.8888888888888888,"#fdca26"],[1.0,"#f0f921"]],"diverging":[[0,"#8e0152"],[0.1,"#c51b7d"],[0.2,"#de77ae"],[0.3,"#f1b6da"],[0.4,"#fde0ef"],[0.5,"#f7f7f7"],[0.6,"#e6f5d0"],[0.7,"#b8e186"],[0.8,"#7fbc41"],[0.9,"#4d9221"],[1,"#276419"]]},"xaxis":{"gridcolor":"white","linecolor":"white","ticks":"","title":{"standoff":15},"zerolinecolor":"white","automargin":true,"zerolinewidth":2},"yaxis":{"gridcolor":"white","linecolor":"white","ticks":"","title":{"standoff":15},"zerolinecolor":"white","automargin":true,"zerolinewidth":2},"scene":{"xaxis":{"backgroundcolor":"#E5ECF6","gridcolor":"white","linecolor":"white","showbackground":true,"ticks":"","zerolinecolor":"white","gridwidth":2},"yaxis":{"backgroundcolor":"#E5ECF6","gridcolor":"white","linecolor":"white","showbackground":true,"ticks":"","zerolinecolor":"white","gridwidth":2},"zaxis":{"backgroundcolor":"#E5ECF6","gridcolor":"white","linecolor":"white","showbackground":true,"ticks":"","zerolinecolor":"white","gridwidth":2}},"shapedefaults":{"line":{"color":"#2a3f5f"}},"annotationdefaults":{"arrowcolor":"#2a3f5f","arrowhead":0,"arrowwidth":1},"geo":{"bgcolor":"white","landcolor":"#E5ECF6","subunitcolor":"white","showland":true,"showlakes":true,"lakecolor":"white"},"title":{"x":0.05},"mapbox":{"style":"light"}}},"autosize":false,"width":1200.0,"height":800.0,"title":{"text":"Graph 5"},"showlegend":true,"xaxis":{"title":{"text":""}},"yaxis":{"title":{"text":""}}},                        {"responsive": true}                    ).then(function(){\n                            \nvar gd = document.getElementById(\'3be660bc-522c-4b8c-aee7-9abf96cb6ed5\');\nvar x = new MutationObserver(function (mutations, observer) {{\n        var display = window.getComputedStyle(gd).display;\n        if (!display || display === \'none\') {{\n            console.log([gd, \'removed!\']);\n            Plotly.purge(gd);\n            observer.disconnect();\n        }}\n}});\n\n// Listen for the removal of the full notebook cells\nvar notebookContainer = gd.closest(\'#notebook-container\');\nif (notebookContainer) {{\n    x.observe(notebookContainer, {childList: true});\n}}\n\n// Listen for the clearing of the current output cell\nvar outputEl = gd.closest(\'.output\');\nif (outputEl) {{\n    x.observe(outputEl, {childList: true});\n}}\n\n                        })                };                });            </script>        </div>'}

Total running time of the script: (1 minutes 31.451 seconds)

Gallery generated by Sphinx-Gallery