{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Plot options\n", "\n", "The `plot()` function in `k3d` module creates a `Plot` object. There are a few options, which control the behavior and apperance of the plot:\n", "\n", "- `height` - vertical size of the plot widget\n", "- `antialias` - enables antialiasing in the WebGL renderer, its effect depends on the WebGL implementation and browser settings. On by default.\n", "- `background_color` - RGB value of the backgound color packed into a single integer.\n", "\n", "Only the last of these options can be effectively changed once the plot is `display()`-ed." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import k3d\n", "plot = k3d.plot(antialias=False, height=320, camera_auto_fit=False, grid_auto_fit=False)\n", "plot += k3d.mesh([0, 0, 0, 1, 0, 0, 0, 0, 1], [0, 1, 2])\n", "plot += k3d.points([0, 0, 0])\n", "\n", "plot.display()\n", "plot.camera = [1.039, -0.196, -0.069, 0.25 , 0. , 0.25 , 0.426, -0.006, 0.905]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plot_aa = k3d.plot(antialias=True, height=320, camera_auto_fit=False, grid_auto_fit=False)\n", "plot_aa += k3d.mesh([0, 0, 0, 1, 0, 0, 0, 0, 1], [0, 1, 2])\n", "plot_aa += k3d.points([0, 0, 0])\n", "\n", "plot_aa.display()\n", "plot_aa.camera = [1.039, -0.196, -0.069, 0.25 , 0. , 0.25 , 0.426, -0.006, 0.905]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Expected results:\n", "\n", "The first plot (antialias=False) should look like this:\n", "![Aliased plot](assets/05_plot_options_1.png \"A plot without antialiasing, note the triangle sides.\")\n", "\n", "The second plot (antialias=True) should look like this:\n", "![Anti-liased plot](assets/05_plot_options_2.png \"A smooth plot with antialiasing.\")\n", "\n", "Some objects, like the point above, are not affected by this settings." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plot.background_color = 0xffff" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Expected result:\n", "\n", "![Background color effect](assets/05_plot_options_3.png \"A colorful backgound.\")\n", "\n", "White and black are the most popular background colors, but any RGB color can be used if so desired." ] }, { "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.6.5" } }, "nbformat": 4, "nbformat_minor": 2 }