{ "cells": [ { "cell_type": "code", "execution_count": null, "id": "aa2c2c2a", "metadata": {}, "outputs": [], "source": [ "from bqplot import Radar" ] }, { "cell_type": "code", "execution_count": null, "id": "e24060e0", "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import numpy as np\n", "\n", "df = pd.DataFrame(np.random.rand(7, 4), columns=list(\"ABCD\"),\n", " index=[f\"R{i+1}\" for i in range(7)])\n", "radar = Radar(data=df, data_range=[0, 1], fill=True, num_bands=5, band_type=\"circle\", animation_duration=1000)\n", "\n", "# radar is a figure so we can update its title\n", "radar.title = \"Radar\"\n", "\n", "# since radar is a figure (which is a DOM widget) we can directly render it\n", "radar" ] }, { "cell_type": "code", "execution_count": null, "id": "bb23866d", "metadata": {}, "outputs": [], "source": [ "#update data\n", "radar.data = pd.DataFrame(np.random.rand(10, 5), columns=list(\"ABCDE\"),\n", " index=[f\"R{i+1}\" for i in range(10)])" ] }, { "cell_type": "code", "execution_count": null, "id": "6e27b684", "metadata": {}, "outputs": [], "source": [ "# change radar type\n", "radar.band_type = \"polygon\"" ] }, { "cell_type": "code", "execution_count": null, "id": "9ad12e64", "metadata": {}, "outputs": [], "source": [ "# no fill\n", "radar.fill = False" ] }, { "cell_type": "code", "execution_count": null, "id": "a460a607", "metadata": {}, "outputs": [], "source": [ "# set number of bands to 8\n", "radar.num_bands = 8" ] }, { "cell_type": "code", "execution_count": null, "id": "27719f18", "metadata": {}, "outputs": [], "source": [ "# since radar is a figure composed of primitive marks we can directly change the internals\n", "# update loop colors\n", "radar.loops.colors = [\"red\", \"magenta\", \"green\", \"orange\"]" ] }, { "cell_type": "code", "execution_count": null, "id": "f35dff18", "metadata": {}, "outputs": [], "source": [ "# remove the band labels\n", "radar.band_labels.text = []" ] }, { "cell_type": "code", "execution_count": null, "id": "42d98577", "metadata": {}, "outputs": [], "source": [ "# remove the spoke labels\n", "radar.spoke_labels.text = []" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.7.12" } }, "nbformat": 4, "nbformat_minor": 5 }