Skip to content

Instantly share code, notes, and snippets.

@ltiao
Created May 23, 2023 10:09
Show Gist options
  • Save ltiao/3edb602999c4bb0e03eb765572ca84da to your computer and use it in GitHub Desktop.
Save ltiao/3edb602999c4bb0e03eb765572ca84da to your computer and use it in GitHub Desktop.
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import pandas as pd\n",
"\n",
"import matplotlib as mpl\n",
"import matplotlib.pyplot as plt\n",
"import seaborn as sns"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"ASPECT = 0.5 * (1 + np.sqrt(5))\n",
"WIDTH = 4.\n",
"HEIGHT = WIDTH / ASPECT\n",
"DPI = 300\n",
"rc = {\n",
" \"figure.figsize\": (WIDTH, HEIGHT),\n",
" \"figure.dpi\": DPI,\n",
" \"font.serif\": [\"Palatino\"],\n",
" \"text.usetex\": True,\n",
" \"savefig.dpi\": DPI,\n",
" \"savefig.transparent\": False\n",
"}\n",
"sns.set(context=\"paper\", style=\"ticks\", palette=\"deep\", font=\"serif\", rc=rc)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"cm = plt.get_cmap(\"Set1\")"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"#E41A1C\n",
"#377EB8\n",
"#4DAF4A\n",
"#984EA3\n",
"#FF7F00\n",
"#FFFF33\n",
"#A65628\n",
"#F781BF\n",
"#999999\n"
]
}
],
"source": [
"for i in range(cm.N):\n",
" rgba = cm(i)\n",
" print(mpl.colors.rgb2hex(rgba).upper())"
]
}
],
"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.10.10"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment