.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/plot_streamThickness.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_plot_streamThickness.py: Plotting: Streamline thickness ============================== A simple example to vary streamline thickness based on the vector amplitudes Author: `@micmitch ` .. GENERATED FROM PYTHON SOURCE LINES 9-14 .. code-block:: default import numpy as np import matplotlib.pyplot as plt from discretize import TensorMesh .. GENERATED FROM PYTHON SOURCE LINES 15-19 Create mesh ----------- Minimum cell size in each direction .. GENERATED FROM PYTHON SOURCE LINES 19-41 .. code-block:: default dx = 1.0 dy = 1.0 dz = 1.0 # Number of core cells in each direction nCoreX = 43.0 nCoreY = 43.0 nCoreZ = 43.0 # Cell widths hx = [(dx, nCoreX)] hy = [(dy, nCoreY)] hz = [(dz, nCoreZ)] # Desired Core mesh origin (Bottom SW corner) x0 = -21.5 y0 = -21.5 z0 = -21.5 mesh = TensorMesh([hx, hy, hz], [x0, y0, z0]) print(mesh.nC) .. rst-class:: sphx-glr-script-out .. code-block:: none 79507 .. GENERATED FROM PYTHON SOURCE LINES 42-45 Define arbitrary function to plot --------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 45-54 .. code-block:: default X = mesh.gridCC[:, 0] Y = mesh.gridCC[:, 1] Z = mesh.gridCC[:, 2] U = -1 - X**2 + Y + Z V = 1 + X - Y**2 + Z W = 1 + X + Y - Z**2 .. GENERATED FROM PYTHON SOURCE LINES 55-59 Plot streamlines ---------------- Create figure .. GENERATED FROM PYTHON SOURCE LINES 59-88 .. code-block:: default fig = plt.figure() ax = plt.subplot(111) fig.set_figheight(15) fig.set_figwidth(15) labelsize = 30.0 ticksize = 30.0 # Create data vector dataVec = np.hstack([U, V, W]) print(dataVec.shape) # Set streamline plotting options stream_opts = {"color": "w", "density": 2.0} pcolor_opts = {"cmap": "viridis"} dat = mesh.plot_slice( dataVec, ax=ax, normal="Z", ind=5, v_type="CCv", view="vec", stream_opts=stream_opts, grid_opts={"color": "k", "alpha": 0.1}, grid=True, clim=None, stream_thickness=3, ) .. image-sg:: /examples/images/sphx_glr_plot_streamThickness_001.png :alt: Slice 5 :srcset: /examples/images/sphx_glr_plot_streamThickness_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none (238521,) .. GENERATED FROM PYTHON SOURCE LINES 89-94 Moving Forward -------------- If you have suggestions for improving this example, please create a pull request on the example in discretize .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.607 seconds) .. _sphx_glr_download_examples_plot_streamThickness.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_streamThickness.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_streamThickness.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_