Debian Codegraph @

ui-tests/tests/notebooks/bars.ipynb

raw
1 {
2 "cells": [
3 {
4 "cell_type": "code",
5 "execution_count": null,
6 "id": "romance-heavy",
7 "metadata": {},
8 "outputs": [],
9 "source": [
10 "from bqplot import *\n",
11 "\n",
12 "import numpy as np\n",
13 "import pandas as pd"
14 ]
15 },
16 {
17 "cell_type": "code",
18 "execution_count": null,
19 "id": "physical-right",
20 "metadata": {},
21 "outputs": [],
22 "source": [
23 "size = 100\n",
24 "np.random.seed(0)\n",
25 "\n",
26 "x_data = range(size)\n",
27 "y_data = np.random.randn(size)\n",
28 "y_data_2 = np.random.randn(size)\n",
29 "y_data_3 = np.cumsum(np.random.randn(size) * 100.)"
30 ]
31 },
32 {
33 "cell_type": "code",
34 "execution_count": null,
35 "id": "excellent-column",
36 "metadata": {},
37 "outputs": [],
38 "source": [
39 "# Create Bar\n",
40 "x_ord = OrdinalScale()\n",
41 "y_sc = LinearScale()\n",
42 "\n",
43 "bar = Bars(x=np.arange(10), y=np.random.rand(10), scales={'x': x_ord, 'y': y_sc})\n",
44 "ax_x = Axis(scale=x_ord)\n",
45 "ax_y = Axis(scale=y_sc, tick_format='0.2f', orientation='vertical')\n",
46 "\n",
47 "fig = Figure(marks=[bar], axes=[ax_x, ax_y], padding_x=0.025, padding_y=0.025)\n",
48 "fig"
49 ]
50 },
51 {
52 "cell_type": "code",
53 "execution_count": null,
54 "id": "valid-rider",
55 "metadata": {},
56 "outputs": [],
57 "source": [
58 "x_ord = OrdinalScale()\n",
59 "y_sc = LinearScale()\n",
60 "\n",
61 "bar = Bars(\n",
62 " x=np.arange(10), \n",
63 " y=np.random.rand(10), \n",
64 " scales={'x': x_ord, 'y': y_sc}, \n",
65 " opacities=[0.5, 0.2, 0.3, 0.8],\n",
66 " colors=['red', 'blue', 'green']\n",
67 ")\n",
68 "ax_x = Axis(scale=x_ord)\n",
69 "ax_y = Axis(scale=y_sc, tick_format='0.2f', orientation='vertical')\n",
70 "\n",
71 "fig = Figure(marks=[bar], axes=[ax_x, ax_y], padding_x=0.025, padding_y=0.025)\n",
72 "fig"
73 ]
74 },
75 {
76 "cell_type": "code",
77 "execution_count": null,
78 "id": "9b7a4696",
79 "metadata": {},
80 "outputs": [],
81 "source": [
82 "x_ord = OrdinalScale()\n",
83 "y_sc = LinearScale()\n",
84 "\n",
85 "bar = Bars(x=np.arange(10), y=np.random.rand(10), scales={'x': x_ord, 'y': y_sc},\n",
86 " label_display=True,\n",
87 " label_display_vertical_offset=-13)\n",
88 "\n",
89 "ax_x = Axis(scale=x_ord)\n",
90 "ax_y = Axis(scale=y_sc, tick_format='0.2f', orientation='vertical')\n",
91 "\n",
92 "Figure(marks=[bar], axes=[ax_x, ax_y], padding_x=0.025, padding_y=0.05)"
93 ]
94 },
95 {
96 "cell_type": "code",
97 "execution_count": null,
98 "id": "68d55c1d",
99 "metadata": {},
100 "outputs": [],
101 "source": [
102 "x_ord = OrdinalScale()\n",
103 "y_sc = LinearScale()\n",
104 "\n",
105 "bar = Bars(x=np.arange(10), y=np.random.rand(10), scales={'x': x_ord, 'y': y_sc},\n",
106 " label_display=True,\n",
107 " label_display_vertical_offset=-13,\n",
108 " label_display_horizontal_offset=-20)\n",
109 "\n",
110 "ax_x = Axis(scale=x_ord)\n",
111 "ax_y = Axis(scale=y_sc, tick_format='0.2f', orientation='vertical')\n",
112 "\n",
113 "Figure(marks=[bar], axes=[ax_x, ax_y], padding_x=0.025, padding_y=0.05)"
114 ]
115 },
116 {
117 "cell_type": "code",
118 "execution_count": null,
119 "id": "ddc9b18f",
120 "metadata": {},
121 "outputs": [],
122 "source": [
123 "x_ord = OrdinalScale()\n",
124 "y_sc = LinearScale()\n",
125 "\n",
126 "bar = Bars(x=np.arange(10), y=np.random.rand(10), scales={'x': x_ord, 'y': y_sc},\n",
127 " label_display=True,\n",
128 " label_display_vertical_offset=-13,\n",
129 " label_display_horizontal_offset=-20,\n",
130 " label_display_format='.3f')\n",
131 "\n",
132 "ax_x = Axis(scale=x_ord)\n",
133 "ax_y = Axis(scale=y_sc, tick_format='0.2f', orientation='vertical')\n",
134 "\n",
135 "Figure(marks=[bar], axes=[ax_x, ax_y], padding_x=0.025, padding_y=0.05)"
136 ]
137 },
138 {
139 "cell_type": "code",
140 "execution_count": null,
141 "id": "6d1d205a",
142 "metadata": {},
143 "outputs": [],
144 "source": [
145 "x_ord = OrdinalScale()\n",
146 "y_sc = LinearScale()\n",
147 "\n",
148 "bar = Bars(x=np.arange(10), y=np.random.rand(10), scales={'x': x_ord, 'y': y_sc},\n",
149 " label_display=True,\n",
150 " label_display_vertical_offset=-13,\n",
151 " label_display_horizontal_offset=-20,\n",
152 " label_display_format='.3f',\n",
153 " label_font_style={ 'fill': 'green' })\n",
154 "\n",
155 "ax_x = Axis(scale=x_ord)\n",
156 "ax_y = Axis(scale=y_sc, tick_format='0.2f', orientation='vertical')\n",
157 "\n",
158 "Figure(marks=[bar], axes=[ax_x, ax_y], padding_x=0.025, padding_y=0.05)"
159 ]
160 }
161 ],
162 "metadata": {
163 "kernelspec": {
164 "display_name": "Python 3",
165 "language": "python",
166 "name": "python3"
167 },
168 "language_info": {
169 "codemirror_mode": {
170 "name": "ipython",
171 "version": 3
172 },
173 "file_extension": ".py",
174 "mimetype": "text/x-python",
175 "name": "python",
176 "nbconvert_exporter": "python",
177 "pygments_lexer": "ipython3",
178 "version": "3.9.5"
179 }
180 },
181 "nbformat": 4,
182 "nbformat_minor": 5
183 }