{ "cells": [ { "cell_type": "code", "execution_count": null, "id": "cdd1e2b7", "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "from bqplot import *\n", "\n", "np.random.seed(0)\n", "data = np.random.randn(10, 10)\n", "\n", "x_sc, y_sc, col_sc = OrdinalScale(), OrdinalScale(reverse=True), ColorScale()\n", "\n", "grid_map = GridHeatMap(color=data, scales={'column': x_sc, 'row': y_sc, 'color': col_sc})\n", "\n", "fig = Figure(marks=[grid_map], padding_y=0.0)\n", "fig" ] }, { "cell_type": "code", "execution_count": null, "id": "94695188", "metadata": {}, "outputs": [], "source": [ "grid_map.display_format = '.2f'" ] }, { "cell_type": "code", "execution_count": null, "id": "e99ba91b", "metadata": {}, "outputs": [], "source": [ "grid_map.font_style={'font-size': '12px', 'fill':'black', 'font-weight': 'bold'}" ] }, { "cell_type": "code", "execution_count": null, "id": "4d8bfae5", "metadata": {}, "outputs": [], "source": [ "grid_map.display_format = None" ] }, { "cell_type": "code", "execution_count": null, "id": "724f7959", "metadata": {}, "outputs": [], "source": [ "ax_x, ax_y = Axis(scale=x_sc), Axis(scale=y_sc, orientation='vertical')\n", "fig.axes = [ax_x, ax_y]" ] }, { "cell_type": "code", "execution_count": null, "id": "da3795f6", "metadata": {}, "outputs": [], "source": [ "grid_map.stroke = 'white'" ] }, { "cell_type": "code", "execution_count": null, "id": "b6bbd1c1", "metadata": {}, "outputs": [], "source": [ "grid_map.opacity=0.5" ] }, { "cell_type": "code", "execution_count": null, "id": "8428a4ce", "metadata": {}, "outputs": [], "source": [ "grid_map.selected_style = {'opacity': '1.0'}\n", "grid_map.unselected_style = {'fill': 'red'}\n", "grid_map.selected = [\n", " [0, 0],\n", " [1, 5],\n", " [5, 5]\n", "]" ] }, { "cell_type": "code", "execution_count": null, "id": "b525a618", "metadata": {}, "outputs": [], "source": [ "grid_map.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 }