Skip to content

Instantly share code, notes, and snippets.

@lkluft
Last active July 28, 2022 14:25
Show Gist options
  • Save lkluft/270f6a5d9f08af56d1a84008fe7b45d6 to your computer and use it in GitHub Desktop.
Save lkluft/270f6a5d9f08af56d1a84008fe7b45d6 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAcAAAAFpCAYAAAALNvhVAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAU80lEQVR4nO3de7BV5X3G8eeRI0FUBDWighVMKYHYoCkTNTYXbwkxRptbByexxstgJ40x1FZRU210Ymk1tzaZpoxB04o6huhIjVFRydh0EioCSUBitV5RIkRFiDeC/vrH2WHORjbneNY6+92H3/czw5yz9lnrXc8sweesd6+1tiNCAABks1PpAAAAlEABAgBSogABAClRgACAlChAAEBKFCAAIKVeC9D2XNtrba/o8dqethfafqjxddTAxgQAoF59OQO8RtK0rV6bJenuiJgg6e7GMgAAg4b7ciO87XGSbo2IgxvLD0r6QESssb2fpB9HxMSBDAoAQJ36+x7g6IhYI0mNr/vUFwkAgIHXNdA7sD1D0gxJ2mX48D85aPxBA73LPolXN5aO0OTFNS+UjtCxdhs3tnQE9NFvH1tdOkKTncbsVzpCk+E7DykdocnKlSt+ExFvrXvc/77npzFyz5GVxnjHIZPu0BvffqtVfwvwGdv79ZgCXdtqxYiYI2mOJB188B/H9+ff0s9d1mvTQ4tKR2iy9B9vLR2hYx1+1VdLR0Af/ezMc0tHaLLLVy4qHaHJlNF7lo7QZPKktz0+EOOO3HOkPn3cZyuN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{
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"import matplotlib as mpl\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"\n",
"\n",
"def streamline_colorbar(colorbar, whitespace=.8):\n",
" colorbar.outline.set_edgecolor('white')\n",
" colorbar.dividers.set_linewidth(whitespace)\n",
" colorbar.ax.tick_params(length=0)\n",
" colorbar.dividers.set_color('white')\n",
" \n",
"\n",
"m = np.random.randn(10, 10)\n",
"fig, ax = plt.subplots(figsize=(8, 6))\n",
"sm = ax.pcolormesh(m, cmap=plt.get_cmap('twilight_shifted', 16))\n",
"cb = fig.colorbar(sm, drawedges=True)\n",
"streamline_colorbar(cb)"
]
}
],
"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.7.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment