Created
September 18, 2019 15:11
-
-
Save klarh/d50a3b81251010f88124517df45beebd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"!pip install plato-draw" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import plato, plato.draw.vispy as draw\n", | |
"import numpy as np" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"Nside = int(np.sqrt(1e5))\n", | |
"positions = np.zeros((Nside, Nside, 2))\n", | |
"positions[:, :, 0] = np.arange(Nside)[:, np.newaxis]\n", | |
"positions[:, :, 1] = np.arange(Nside)[np.newaxis, :]\n", | |
"positions = positions.reshape((-1, 2))\n", | |
"positions -= Nside/2\n", | |
"angles = np.arctan2(positions[:, 1], positions[:, 0]) + np.pi/5\n", | |
"colors = np.ones((Nside**2, 4))\n", | |
"colors[:, :3] = plato.cmap.cubeellipse(angles)\n", | |
"\n", | |
"magnitudes = 1 + np.cos(np.linalg.norm(positions, axis=-1)/20)**(2)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"vertices = [(.5, .25), (-.5, .25), (-.5, -.25), (.5, -.25)]\n", | |
"prim = draw.Arrows2D(positions=positions, angles=angles, colors=colors,\n", | |
" vertices=vertices, magnitudes=magnitudes)\n", | |
"features = dict(pan=True)\n", | |
"scene = draw.Scene(prim, features=features)\n", | |
"scene.show()" | |
] | |
}, | |
{ | |
"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.4" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment