{ "cells": [ { "cell_type": "code", "execution_count": null, "id": "choice-grave", "metadata": {}, "outputs": [], "source": [ "from bqplot import *\n", "\n", "import numpy as np\n", "import pandas as pd\n", "\n", "size = 20\n", "np.random.seed(0)\n", "\n", "x_data = range(size)\n", "y_data = np.random.randn(size)\n", "y_data_2 = np.random.randn(size)\n", "y_data_3 = np.cumsum(np.random.randn(size) * 100.)\n", "\n", "# Create Bar\n", "x_ord = OrdinalScale()\n", "y_sc = LinearScale()\n", "\n", "bar = Bars(x=x_data, y=y_data, scales={'x': x_ord, 'y': y_sc})\n", "ax_x = Axis(scale=x_ord)\n", "ax_y = Axis(scale=y_sc, tick_format='0.2f', orientation='vertical')\n", "\n", "fig = Figure(marks=[bar], axes=[ax_x, ax_y], padding_x=0.025, padding_y=0.025)\n", "fig" ] }, { "cell_type": "code", "execution_count": null, "id": "local-providence", "metadata": {}, "outputs": [], "source": [ "bar.opacities = [0.5, 0.2, 0.3, 0.8]" ] }, { "cell_type": "code", "execution_count": null, "id": "careful-morning", "metadata": {}, "outputs": [], "source": [ "bar.colors = ['red', 'blue', 'green']" ] }, { "cell_type": "code", "execution_count": null, "id": "invisible-hurricane", "metadata": {}, "outputs": [], "source": [ "bar.y = y_data_2" ] }, { "cell_type": "code", "execution_count": null, "id": "waiting-florence", "metadata": {}, "outputs": [], "source": [ "bar.stroke = 'black'" ] }, { "cell_type": "code", "execution_count": null, "id": "clean-fiber", "metadata": {}, "outputs": [], "source": [ "bar.stroke_width = 3" ] }, { "cell_type": "code", "execution_count": null, "id": "defensive-resistance", "metadata": {}, "outputs": [], "source": [ "bar.scales = dict(x=x_ord, y=y_sc, color=ColorScale())\n", "bar.color = -bar.y" ] }, { "cell_type": "code", "execution_count": null, "id": "clear-england", "metadata": {}, "outputs": [], "source": [ "bar.selected_style = dict(fill='green')\n", "bar.unselected_style = dict(fill='red')\n", "bar.selected = list(range(9, 12))" ] }, { "cell_type": "code", "execution_count": null, "id": "starting-prevention", "metadata": {}, "outputs": [], "source": [ "bar.selected = None" ] } ], "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.9.2" } }, "nbformat": 4, "nbformat_minor": 5 }