Created
April 7, 2022 14:17
-
-
Save astrofrog/9069845bef13e20afe5a536550cb6811 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": 1, | |
"id": "72b952ce", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import numpy as np\n", | |
"# large data to make draws slow (deliberately)\n", | |
"x = np.random.random(20000)\n", | |
"y = np.random.random(20000)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"id": "8bda7fe6", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"application/vnd.jupyter.widget-view+json": { | |
"model_id": "16008115de3f4b0a929540f16732426a", | |
"version_major": 2, | |
"version_minor": 0 | |
}, | |
"text/plain": [ | |
"Figure(axes=[Axis(label='x', scale=LinearScale(allow_padding=False, max=10.0, min=0.0)), Axis(label='y', orien…" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"from bqplot import Figure, LinearScale, Axis, Lines\n", | |
"scale_x = LinearScale(min=0, max=10, allow_padding=False)\n", | |
"scale_y = LinearScale(allow_padding=False)\n", | |
"scales = {'x': scale_x, 'y': scale_y}\n", | |
"axis_x = Axis(scale=scale_x, label='x')\n", | |
"axis_y = Axis(scale=scale_y, label='y', orientation='vertical')\n", | |
"line = Lines(x=x, y=y+0.2, scales=scales)\n", | |
"figure = Figure(scales=scales, axes=[axis_x, axis_y], marks=[line])\n", | |
"figure" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"id": "70e94513", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"with scale_x.hold_trait_notifications():\n", | |
" with scale_y.hold_trait_notifications():\n", | |
" scale_x.min = -1\n", | |
" scale_x.max = +12\n", | |
" scale_y.min = -10\n", | |
" scale_y.max = +20" | |
] | |
} | |
], | |
"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.9.5" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 5 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment