Debian Codegraph @

bqplot/ui-tests/tests/notebooks/bars_update.ipynb

raw
1 {
2 "cells": [
3 {
4 "cell_type": "code",
5 "execution_count": null,
6 "id": "choice-grave",
7 "metadata": {},
8 "outputs": [],
9 "source": [
10 "from bqplot import *\n",
11 "\n",
12 "import numpy as np\n",
13 "import pandas as pd\n",
14 "\n",
15 "size = 20\n",
16 "np.random.seed(0)\n",
17 "\n",
18 "x_data = range(size)\n",
19 "y_data = np.random.randn(size)\n",
20 "y_data_2 = np.random.randn(size)\n",
21 "y_data_3 = np.cumsum(np.random.randn(size) * 100.)\n",
22 "\n",
23 "# Create Bar\n",
24 "x_ord = OrdinalScale()\n",
25 "y_sc = LinearScale()\n",
26 "\n",
27 "bar = Bars(x=x_data, y=y_data, scales={'x': x_ord, 'y': y_sc})\n",
28 "ax_x = Axis(scale=x_ord)\n",
29 "ax_y = Axis(scale=y_sc, tick_format='0.2f', orientation='vertical')\n",
30 "\n",
31 "fig = Figure(marks=[bar], axes=[ax_x, ax_y], padding_x=0.025, padding_y=0.025)\n",
32 "fig"
33 ]
34 },
35 {
36 "cell_type": "code",
37 "execution_count": null,
38 "id": "local-providence",
39 "metadata": {},
40 "outputs": [],
41 "source": [
42 "bar.opacities = [0.5, 0.2, 0.3, 0.8]"
43 ]
44 },
45 {
46 "cell_type": "code",
47 "execution_count": null,
48 "id": "careful-morning",
49 "metadata": {},
50 "outputs": [],
51 "source": [
52 "bar.colors = ['red', 'blue', 'green']"
53 ]
54 },
55 {
56 "cell_type": "code",
57 "execution_count": null,
58 "id": "invisible-hurricane",
59 "metadata": {},
60 "outputs": [],
61 "source": [
62 "bar.y = y_data_2"
63 ]
64 },
65 {
66 "cell_type": "code",
67 "execution_count": null,
68 "id": "waiting-florence",
69 "metadata": {},
70 "outputs": [],
71 "source": [
72 "bar.stroke = 'black'"
73 ]
74 },
75 {
76 "cell_type": "code",
77 "execution_count": null,
78 "id": "clean-fiber",
79 "metadata": {},
80 "outputs": [],
81 "source": [
82 "bar.stroke_width = 3"
83 ]
84 },
85 {
86 "cell_type": "code",
87 "execution_count": null,
88 "id": "defensive-resistance",
89 "metadata": {},
90 "outputs": [],
91 "source": [
92 "bar.scales = dict(x=x_ord, y=y_sc, color=ColorScale())\n",
93 "bar.color = -bar.y"
94 ]
95 },
96 {
97 "cell_type": "code",
98 "execution_count": null,
99 "id": "clear-england",
100 "metadata": {},
101 "outputs": [],
102 "source": [
103 "bar.selected_style = dict(fill='green')\n",
104 "bar.unselected_style = dict(fill='red')\n",
105 "bar.selected = list(range(9, 12))"
106 ]
107 },
108 {
109 "cell_type": "code",
110 "execution_count": null,
111 "id": "starting-prevention",
112 "metadata": {},
113 "outputs": [],
114 "source": [
115 "bar.selected = None"
116 ]
117 }
118 ],
119 "metadata": {
120 "kernelspec": {
121 "display_name": "Python 3",
122 "language": "python",
123 "name": "python3"
124 },
125 "language_info": {
126 "codemirror_mode": {
127 "name": "ipython",
128 "version": 3
129 },
130 "file_extension": ".py",
131 "mimetype": "text/x-python",
132 "name": "python",
133 "nbconvert_exporter": "python",
134 "pygments_lexer": "ipython3",
135 "version": "3.9.2"
136 }
137 },
138 "nbformat": 4,
139 "nbformat_minor": 5
140 }