Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: #475 adding labels #474

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 91 additions & 0 deletions 3d single view labeling.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "34484b43-fc8c-40d7-b092-53e4187cf5f5",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "e92daa06efc147d09cedcbafd45609c6",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Widget(value='<iframe src=\"http://localhost:54309/index.html?ui=P_0x21dca2c8b60_0&reconnect=auto\" class=\"pyvis…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import pyvista as pv\n",
"from pyvista import examples\n",
"\n",
"# Download a sample mesh (bunny model)\n",
"mesh = examples.download_bunny_coarse()\n",
"\n",
"# Create a Plotter object\n",
"pl = pv.Plotter()\n",
"\n",
"# Add the bunny mesh to the plotter\n",
"pl.add_mesh(mesh, show_edges=True, color='white')\n",
"\n",
"# Add points on the mesh (for visualization, not necessary for labeling)\n",
"#pl.add_points(mesh.points, color='red', point_size=20)\n",
"\n",
"# Define the coordinates and labels for different parts of the bunny model\n",
"labels = {\n",
" \"Ear Left\": [-0.08508963,0.15244128,-0.07269581],\n",
" \"Ear Right\": [-0.01597024,0.13926028,-0.02299697],\n",
" \"Nose\": [-0.11643464,0.05128627,0.07609549],\n",
" \"Bottom\": [0.14346997,-0.08839463,0.04595339],\n",
"}\n",
"\n",
"# Add labels to the plotter\n",
"for label, coord in labels.items():\n",
" pl.add_point_labels([coord], [label], point_color='blue', point_size=10, font_size=20, text_color='black')\n",
"\n",
"# Set the camera position for a better view\n",
"pl.camera_position = [(0.02, 0.30, 0.73),\n",
" (0.02, 0.03, -0.022),\n",
" (-0.03, 0.94, -0.34)]\n",
"\n",
"# Show the plot\n",
"pl.show()\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6b3d7b67-fb11-4edb-9d83-47e66a794568",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.12.0"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading