{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## 3D Orthographic Projection\n", "It's now possible to specify the 3D projection to be either `'perspective'` or `'orthograhic'`" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "3.7.0\n" ] }, { "data": { "text/html": [ "" ], "text/vnd.plotly.v1+html": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import numpy as np\n", "import plotly\n", "print(plotly.__version__)\n", "\n", "import plotly.graph_objs as go\n", "from plotly.offline import init_notebook_mode, iplot\n", "from plotly.tools import make_subplots\n", "init_notebook_mode()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Default `'perspective'` projection" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "linkText": "Export to plot.ly", "plotlyServerURL": "https://plot.ly", "showLink": false }, "data": [ { "type": "scatter3d", "uid": "67d715f6-fc17-4e47-9dd6-5698a8639995", "x": [ 0, 1, 2, 3 ], "y": [ "A", "B", "C", "B" ], "z": [ 1, 3, 2, 1 ] } ], "layout": { "title": { "text": "Perspective projection" } } }, "text/html": [ "
" ], "text/vnd.plotly.v1+html": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "fig = go.Figure()\n", "scatter3d = fig.add_scatter3d(\n", " x=[0, 1, 2, 3],\n", " y=[\"A\", \"B\", \"C\", \"B\"],\n", " z=[1, 3, 2, 1])\n", "fig.layout.title.text = 'Perspective projection'\n", "iplot(fig)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "New orthographic projection" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "linkText": "Export to plot.ly", "plotlyServerURL": "https://plot.ly", "showLink": false }, "data": [ { "type": "scatter3d", "uid": "67d715f6-fc17-4e47-9dd6-5698a8639995", "x": [ 0, 1, 2, 3 ], "y": [ "A", "B", "C", "B" ], "z": [ 1, 3, 2, 1 ] } ], "layout": { "scene": { "camera": { "projection": { "type": "orthographic" } } }, "title": { "text": "Orthographic projection" } } }, "text/html": [ "" ], "text/vnd.plotly.v1+html": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "fig.layout.title.text = 'Orthographic projection'\n", "fig.layout.scene.camera.projection.type = \"orthographic\"\n", "iplot(fig)" ] }, { "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.2" } }, "nbformat": 4, "nbformat_minor": 2 }