{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Colors and Colormaps"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"from random import shuffle\n",
"from algorithm_visualizer import alvito\n",
"from utils import random_array\n",
"import matplotlib.pyplot as plt\n",
"from IPython.display import HTML, display\n",
"from IPython.utils import io"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Colors\n",
"\n",
"All the named colors in matplotlib, read more about them [here](https://matplotlib.org/examples/color/named_colors.html).\n",
"\n",
""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Colormaps\n",
"In this notebook we are gonna take a look at the different built-in colormaps in \n",
"matplotlib. You can find more details about the colormaps [here](https://matplotlib.org/tutorials/colors/colormaps.html)."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"avo = alvito()\n",
"avo.fps = 1\n",
"avo.show_xlable = False\n",
"avo.title_fontsize = 9\n",
"avo.rectangle_linewidth = 2\n",
"avo.dpi = 80\n",
"\n",
"avo.save_dir = 'cmap_gifs/'\n",
"avo.custom_save_name = True\n",
"\n",
"shape = (10,1)\n",
"array = random_array(shape)\n",
"\n",
"with io.capture_output() as captured: # supressing output when looping over all the cmaps\n",
" for cmap_name in plt.colormaps():\n",
" avo.colormap = cmap_name\n",
" avo.save_name = cmap_name\n",
" avo.insertionSort(array, cmap_name)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"for i in range(0,len(plt.colormaps()),11):\n",
" display_sting = \"\"\n",
" for cmap in plt.colormaps()[i:i+11]:\n",
" display_sting += f' | '\n",
" display_sting += \"
\"\n",
" display(HTML(display_sting))"
]
}
],
"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.1"
}
},
"nbformat": 4,
"nbformat_minor": 2
}