Debian Codegraph @

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

raw
1 {
2 "cells": [
3 {
4 "cell_type": "code",
5 "execution_count": null,
6 "id": "excellent-column",
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 = 100\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=np.arange(10), y=np.random.rand(10), 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": "valid-rider",
39 "metadata": {},
40 "outputs": [],
41 "source": [
42 "x_ord = OrdinalScale()\n",
43 "y_sc = LinearScale()\n",
44 "\n",
45 "bar = Bars(\n",
46 " x=np.arange(10), \n",
47 " y=np.random.rand(10), \n",
48 " scales={'x': x_ord, 'y': y_sc}, \n",
49 " opacities=[0.5, 0.2, 0.3, 0.8],\n",
50 " colors=['red', 'blue', 'green']\n",
51 ")\n",
52 "ax_x = Axis(scale=x_ord)\n",
53 "ax_y = Axis(scale=y_sc, tick_format='0.2f', orientation='vertical')\n",
54 "\n",
55 "fig = Figure(marks=[bar], axes=[ax_x, ax_y], padding_x=0.025, padding_y=0.025)\n",
56 "fig"
57 ]
58 },
59 {
60 "cell_type": "code",
61 "execution_count": null,
62 "id": "9b7a4696",
63 "metadata": {},
64 "outputs": [],
65 "source": [
66 "x_ord = OrdinalScale()\n",
67 "y_sc = LinearScale()\n",
68 "\n",
69 "bar = Bars(x=np.arange(10), y=np.random.rand(10), scales={'x': x_ord, 'y': y_sc},\n",
70 " label_display=True,\n",
71 " label_display_vertical_offset=-13)\n",
72 "\n",
73 "ax_x = Axis(scale=x_ord)\n",
74 "ax_y = Axis(scale=y_sc, tick_format='0.2f', orientation='vertical')\n",
75 "\n",
76 "Figure(marks=[bar], axes=[ax_x, ax_y], padding_x=0.025, padding_y=0.05)"
77 ]
78 },
79 {
80 "cell_type": "code",
81 "execution_count": null,
82 "id": "68d55c1d",
83 "metadata": {},
84 "outputs": [],
85 "source": [
86 "x_ord = OrdinalScale()\n",
87 "y_sc = LinearScale()\n",
88 "\n",
89 "bar = Bars(x=np.arange(10), y=np.random.rand(10), scales={'x': x_ord, 'y': y_sc},\n",
90 " label_display=True,\n",
91 " label_display_vertical_offset=-13,\n",
92 " label_display_horizontal_offset=-20)\n",
93 "\n",
94 "ax_x = Axis(scale=x_ord)\n",
95 "ax_y = Axis(scale=y_sc, tick_format='0.2f', orientation='vertical')\n",
96 "\n",
97 "Figure(marks=[bar], axes=[ax_x, ax_y], padding_x=0.025, padding_y=0.05)"
98 ]
99 },
100 {
101 "cell_type": "code",
102 "execution_count": null,
103 "id": "ddc9b18f",
104 "metadata": {},
105 "outputs": [],
106 "source": [
107 "x_ord = OrdinalScale()\n",
108 "y_sc = LinearScale()\n",
109 "\n",
110 "bar = Bars(x=np.arange(10), y=np.random.rand(10), scales={'x': x_ord, 'y': y_sc},\n",
111 " label_display=True,\n",
112 " label_display_vertical_offset=-13,\n",
113 " label_display_horizontal_offset=-20,\n",
114 " label_display_format='.3f')\n",
115 "\n",
116 "ax_x = Axis(scale=x_ord)\n",
117 "ax_y = Axis(scale=y_sc, tick_format='0.2f', orientation='vertical')\n",
118 "\n",
119 "Figure(marks=[bar], axes=[ax_x, ax_y], padding_x=0.025, padding_y=0.05)"
120 ]
121 },
122 {
123 "cell_type": "code",
124 "execution_count": null,
125 "id": "6d1d205a",
126 "metadata": {},
127 "outputs": [],
128 "source": [
129 "x_ord = OrdinalScale()\n",
130 "y_sc = LinearScale()\n",
131 "\n",
132 "bar = Bars(x=np.arange(10), y=np.random.rand(10), scales={'x': x_ord, 'y': y_sc},\n",
133 " label_display=True,\n",
134 " label_display_vertical_offset=-13,\n",
135 " label_display_horizontal_offset=-20,\n",
136 " label_display_format='.3f',\n",
137 " label_font_style={ 'fill': 'green' })\n",
138 "\n",
139 "ax_x = Axis(scale=x_ord)\n",
140 "ax_y = Axis(scale=y_sc, tick_format='0.2f', orientation='vertical')\n",
141 "\n",
142 "Figure(marks=[bar], axes=[ax_x, ax_y], padding_x=0.025, padding_y=0.05)"
143 ]
144 }
145 ],
146 "metadata": {
147 "kernelspec": {
148 "display_name": "Python 3 (ipykernel)",
149 "language": "python",
150 "name": "python3"
151 },
152 "language_info": {
153 "codemirror_mode": {
154 "name": "ipython",
155 "version": 3
156 },
157 "file_extension": ".py",
158 "mimetype": "text/x-python",
159 "name": "python",
160 "nbconvert_exporter": "python",
161 "pygments_lexer": "ipython3",
162 "version": "3.10.0"
163 }
164 },
165 "nbformat": 4,
166 "nbformat_minor": 5
167 }