{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Plotting over triangulated surfaces" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plotly.com" }, "data": [ { "type": "contour", "x": [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 360, 360, 360, 360, 360, 360, 360, 360, 360, 360, 360, 480, 480, 480, 480, 480, 480, 480, 480, 480, 480, 480, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 720, 720, 720, 720, 720, 720, 720, 720, 720, 720, 720, 840, 840, 840, 840, 840, 840, 840, 840, 840, 840, 840, 960, 960, 960, 960, 960, 960, 960, 960, 960, 960, 960, 1080, 1080, 1080, 1080, 1080, 1080, 1080, 1080, 1080, 1080, 1080, 1200, 1200, 1200, 1200, 1200, 1200, 1200, 1200, 1200, 1200, 1200 ], "y": [ 0, 60, 120, 180, 240, 300, 360, 420, 480, 540, 600, 0, 60, 120, 180, 240, 300, 360, 420, 480, 540, 600, 0, 60, 120, 180, 240, 300, 360, 420, 480, 540, 600, 0, 60, 120, 180, 240, 300, 360, 420, 480, 540, 600, 0, 60, 120, 180, 240, 300, 360, 420, 480, 540, 600, 0, 60, 120, 180, 240, 300, 360, 420, 480, 540, 600, 0, 60, 120, 180, 240, 300, 360, 420, 480, 540, 600, 0, 60, 120, 180, 240, 300, 360, 420, 480, 540, 600, 0, 60, 120, 180, 240, 300, 360, 420, 480, 540, 600, 0, 60, 120, 180, 240, 300, 360, 420, 480, 540, 600, 0, 60, 120, 180, 240, 300, 360, 420, 480, 540, 600 ], "z": [ 0.12346276813579982, 0.2520310136656546, 0.17971653353853, 0.5125782123909325, 0.6655004647296162, 0.915156953796837, 0.4664104621955091, 0.8500899992101588, 0.36889910638275025, 0.16807443789587329, 0.7592046989154124, 0.739907650671432, 0.48529129570989327, 0.006162591791996519, 0.3401939247560828, 0.9851204135936195, 0.8874063565370665, 0.688693472704123, 0.4555193589609985, 0.7897768379299984, 0.8420976941363273, 0.13196253473390174, 0.03664221093094466, 0.23648744180031545, 0.030421568416605704, 0.7409492842179469, 0.6309231441198903, 0.12455727171319109, 0.5925470509666868, 0.3116189116981605, 0.8300313681392043, 0.1836859873489598, 0.10735460806799801, 0.8439977096211273, 0.03580665107437886, 0.908157563525284, 0.40051248815818363, 0.5148730360813993, 0.4165631057455095, 0.5194641008075118, 0.9921981033181954, 0.5304201253575334, 0.22171218150126626, 0.9437971596271927, 0.8812138268559851, 0.17437138464871516, 0.9726033734474715, 0.6596370957428566, 0.1137024357031936, 0.7237214732994974, 0.4305478262552104, 0.6385591989513117, 0.23650132281555347, 0.16432591365635318, 0.12422174632930638, 0.0731640418616234, 0.28773332476216995, 0.9799719629227172, 0.20195750854232963, 0.4891195634396406, 0.0137370866371046, 0.37075389744900045, 0.8721063276366721, 0.5783230106999786, 0.8815363894048248, 0.848228674874069, 0.5820811687710686, 0.5434200526839686, 0.12456998871776659, 0.5775566017704036, 0.6938043652337074, 0.8754571649339392, 0.21138818906315304, 0.3321768809925142, 0.5122788408117424, 0.14267196068056998, 0.9974252000560767, 0.5992104655451795, 0.6761459722212617, 0.0393064914634359, 0.41361333403706946, 0.7064181115308386, 0.9369305608496611, 0.27579207173915865, 0.5251451700398048, 0.15985969490940277, 0.08340080259324356, 0.6678885467147677, 0.26740997325271953, 0.8268848884250211, 0.587190020427141, 0.04049524900643631, 0.4213328879577186, 0.08839238982751574, 0.9380310092866856, 0.45089493492702326, 0.9468673531277387, 0.9488012795458534, 0.8474029718677876, 0.45127774529152276, 0.7154133690457379, 0.02668138747522253, 0.300021116181745, 0.7405678579831412, 0.815994433181535, 0.29594574887706593, 0.1396263668835399, 0.8304851776280043, 0.7934219941400145, 0.017719274953736153, 0.30398069831248375, 0.6444934268634815, 0.1400207763348792, 0.6360014761574397, 0.9671674427608947, 0.6061796186102583, 0.5994038405904827, 0.985344203359162, 0.15958774850796287, 0.619393218406217, 0.8000730401006858 ], "zmax": 0.9974252000560767, "zmin": 0.006162591791996519 } ], "layout": { "paper_bgcolor": "white", "plot_bgcolor": "white", "template": { "data": { "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" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "barpolar" } ], "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" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 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, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 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, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 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, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 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, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 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, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "fillpattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 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, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "autotypenumbers": "strict", "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "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" ] ], "sequential": [ [ 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, "#f0f921" ] ], "sequentialminus": [ [ 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, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } }, "xaxis": { "showticklabels": false }, "yaxis": { "scaleanchor": "x", "showticklabels": false } } } }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from sigmaepsilon.mesh.grid import grid\n", "from sigmaepsilon.mesh.utils.topology.tr import Q4_to_T3\n", "from sigmaepsilon.plotting.plotly import plot_triangles_2d\n", "import numpy as np\n", "import plotly\n", "\n", "gridparams = {\n", " 'size' : (1200, 600),\n", " 'shape' : (10, 10),\n", " 'eshape' : (2, 2),\n", "}\n", "coordsQ4, topoQ4 = grid(**gridparams)\n", "points, triangles = Q4_to_T3(coordsQ4, topoQ4, path='grid')\n", "fig = plot_triangles_2d(points, np.random.rand(len(points)))\n", "plotly.io.show(fig)" ] } ], "metadata": { "kernelspec": { "display_name": ".plotting.plotly", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.10" }, "orig_nbformat": 4 }, "nbformat": 4, "nbformat_minor": 2 }