{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "50add2d8e16f476eaed143af8eed1b0d", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Output()" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import k3d\n", "\n", "vertices = [\n", " -10, 0, -1,\n", " 10, 0, -1,\n", " 10, 0, 1,\n", " -10, 0, 1,\n", "]\n", "\n", "indices = [\n", " 0, 1, 3,\n", " 1, 2, 3\n", "]\n", "\n", "plot = k3d.plot()\n", "plot += k3d.mesh(vertices, indices)\n", "plot.display()" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "scrolled": true }, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "83f544e5711146808d29b32fd602affd", "version_major": 2, "version_minor": 0 }, "text/plain": [ "interactive(children=(Dropdown(description='Basic ColorMap:', options=('Binary', 'BlackBodyRadiation', 'Blues'…" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "7ef8525d413b4141b844ea47d1677f09", "version_major": 2, "version_minor": 0 }, "text/plain": [ "interactive(children=(Dropdown(description='ParaView ColorMap:', options=('Asymmtrical_Earth_Tones_6_two_1b', …" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "4d06db2bb4a242f9857c36069592d078", "version_major": 2, "version_minor": 0 }, "text/plain": [ "interactive(children=(Dropdown(description='MatplolLib ColorMap:', options=('Accent', 'Accent_r', 'Afmhot', 'A…" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "013880662afe4e21984b7bd98c9850ac", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Output()" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from ipywidgets import widgets,interact\n", "\n", "vertex_attribute = [0, 1, 1, 0]\n", "\n", "plot = k3d.plot()\n", "mesh = k3d.mesh(vertices, indices, attribute=vertex_attribute, color_map=k3d.basic_color_maps.CoolWarm, color_range=[0.0, 1.0])\n", "plot += mesh\n", "\n", "basic_color_maps = [attr for attr in dir(k3d.basic_color_maps) if not attr.startswith('__')]\n", "paraview_color_maps = [attr for attr in dir(k3d.paraview_color_maps) if not attr.startswith('__')]\n", "matplotlib_color_maps = [attr for attr in dir(k3d.matplotlib_color_maps) if not attr.startswith('__')]\n", "\n", "@interact(x=widgets.Dropdown(options=basic_color_maps, value=basic_color_maps[0], description='Basic ColorMap:'))\n", "def g(x):\n", " mesh.color_map = getattr(k3d.basic_color_maps, x)\n", "\n", "@interact(x=widgets.Dropdown(options=paraview_color_maps, value=paraview_color_maps[0], description='ParaView ColorMap:'))\n", "def g(x):\n", " mesh.color_map = getattr(k3d.paraview_color_maps, x)\n", " \n", "@interact(x=widgets.Dropdown(options=matplotlib_color_maps, value=matplotlib_color_maps[0], description='MatplolLib ColorMap:'))\n", "def g(x):\n", " mesh.color_map = getattr(k3d.matplotlib_color_maps, x)\n", "\n", "plot.display()" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "# show vertex numbers:\n", "import numpy as np\n", "v = np.array(vertices).reshape((len(vertices)//3, 3))\n", "for i, pos in enumerate(v):\n", " plot += k3d.text(text=str(i), position=pos, color=0, reference_point='cc')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.7.3" }, "nbTranslate": { "displayLangs": [ "en", "pl" ], "hotkey": "alt-t", "langInMainMenu": true, "sourceLang": "pl", "targetLang": "en", "useGoogleTranslate": true } }, "nbformat": 4, "nbformat_minor": 2 }