|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "code", |
| 5 | + "execution_count": null, |
| 6 | + "id": "366676b7-f66f-4351-907e-877f6d1817dc", |
| 7 | + "metadata": {}, |
| 8 | + "outputs": [], |
| 9 | + "source": [ |
| 10 | + "import pyvista\n", |
| 11 | + "import numpy as np\n", |
| 12 | + "\n", |
| 13 | + "pyvista.global_theme.show_scalar_bar = False\n", |
| 14 | + "pyvista.global_theme.antialiasing = True\n", |
| 15 | + "pyvista.set_jupyter_backend('pythreejs')\n", |
| 16 | + "\n", |
| 17 | + "def make_cube(center=(0, 0, 0), resolution=1):\n", |
| 18 | + " cube = pyvista.Cube(center=center)\n", |
| 19 | + " return cube.clean().triangulate().subdivide(resolution)\n", |
| 20 | + "\n", |
| 21 | + "pl = pyvista.Plotter()\n", |
| 22 | + "\n", |
| 23 | + "# test face scalars with no lighting\n", |
| 24 | + "mesh = make_cube(center=(-1, 0, -1))\n", |
| 25 | + "mesh['scalars_a'] = np.arange(mesh.n_faces)\n", |
| 26 | + "pl.add_mesh(mesh, lighting=False, cmap='jet', show_edges=True)\n", |
| 27 | + "\n", |
| 28 | + "# test point scalars on a surface mesh\n", |
| 29 | + "mesh = make_cube(center=(1, 0, 1))\n", |
| 30 | + "mesh['scalars_b'] = mesh.points[:, 2]*mesh.points[:, 0]\n", |
| 31 | + "pl.add_mesh(mesh, cmap='bwr', line_width=1)\n", |
| 32 | + "\n", |
| 33 | + "mesh = make_cube(center=(-1, 0, 1))\n", |
| 34 | + "mesh['scalars_c'] = mesh.points[:, 2]\n", |
| 35 | + "pl.add_mesh(mesh, style='points', point_size=30)\n", |
| 36 | + "\n", |
| 37 | + "# test wireframe\n", |
| 38 | + "mesh = make_cube(center=(1, 0, -1))\n", |
| 39 | + "mesh['scalars_d'] = mesh.points[:, 2]\n", |
| 40 | + "pl.add_mesh(mesh, show_edges=False, line_width=3,\n", |
| 41 | + " style='wireframe', cmap='inferno')\n", |
| 42 | + "\n", |
| 43 | + "pl.camera_position = 'xz'\n", |
| 44 | + "pl.show()" |
| 45 | + ] |
| 46 | + } |
| 47 | + ], |
| 48 | + "metadata": { |
| 49 | + "kernelspec": { |
| 50 | + "display_name": "Python 3 (ipykernel)", |
| 51 | + "language": "python", |
| 52 | + "name": "python3" |
| 53 | + }, |
| 54 | + "language_info": { |
| 55 | + "codemirror_mode": { |
| 56 | + "name": "ipython", |
| 57 | + "version": 3 |
| 58 | + }, |
| 59 | + "file_extension": ".py", |
| 60 | + "mimetype": "text/x-python", |
| 61 | + "name": "python", |
| 62 | + "nbconvert_exporter": "python", |
| 63 | + "pygments_lexer": "ipython3", |
| 64 | + "version": "3.9.7" |
| 65 | + } |
| 66 | + }, |
| 67 | + "nbformat": 4, |
| 68 | + "nbformat_minor": 5 |
| 69 | +} |
0 commit comments