{ "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", "np.random.seed(0)\n", "\n", "x = np.arange(10)\n", "y = np.cumsum(np.random.randn(3, 10), axis=1)\n", "\n", "x_ord = OrdinalScale(domain=list(range(15)))\n", "y_sc = LinearScale()\n", "\n", "ax_x = Axis(scale=x_ord, set_ticks=True, grid_lines='none')\n", "ax_y = Axis(scale=y_sc, grid_lines='none', orientation='vertical')\n", "\n", "bar = Bars(\n", " x=x, y=y,\n", " colors=['hotpink', 'orange', 'green'],\n", " labels=['One', 'Two', 'Three'],\n", " display_legend=True,\n", " scales={'x': x_ord, 'y': y_sc}\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": "2d1ffd4f", "metadata": {}, "outputs": [], "source": [ "bar.colors = ['lightblue', 'lightgreen', 'orange']" ] }, { "cell_type": "code", "execution_count": null, "id": "47ebb15e", "metadata": {}, "outputs": [], "source": [ "bar.labels = ['type1', 'type2', 'type3']" ] }, { "cell_type": "code", "execution_count": null, "id": "invisible-hurricane", "metadata": {}, "outputs": [], "source": [ "bar.y = - bar.y" ] }, { "cell_type": "code", "execution_count": null, "id": "waiting-florence", "metadata": {}, "outputs": [], "source": [ "bar.stroke = 'white'" ] }, { "cell_type": "code", "execution_count": null, "id": "clean-fiber", "metadata": {}, "outputs": [], "source": [ "bar.stroke_width = 2" ] }, { "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(4, 6))" ] }, { "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 }