-
-
Save EvanMarie/24c5c597033489a320e63dcec20bb8df to your computer and use it in GitHub Desktop.
line_graph.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"nbformat": 4, | |
"nbformat_minor": 0, | |
"metadata": { | |
"colab": { | |
"provenance": [], | |
"authorship_tag": "ABX9TyMKLhoEo5gF13MnWjvHaT3Y", | |
"include_colab_link": true | |
}, | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3" | |
}, | |
"language_info": { | |
"name": "python" | |
} | |
}, | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "view-in-github", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"<a href=\"https://colab.research.google.com/gist/EvanMarie/24c5c597033489a320e63dcec20bb8df/line_graph.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"id": "3Pbhahof_7st" | |
}, | |
"outputs": [], | |
"source": [ | |
"def line_graph(data, start=None, end=None, close_column=\"close\",\n", | |
" title=None, xlabel=None, ylabel=None):\n", | |
" \n", | |
" import matplotlib as mpl\n", | |
" import matplotlib.pyplot as plt\n", | |
" import random\n", | |
" colors = ['tomato', 'yellow', 'peachpuff', 'lime', 'turquoise',\n", | |
" 'aqua', 'deepskyblue', 'dodgerblue', 'cornflowerblue', 'lavender',\n", | |
" 'violet', 'fuchsia', 'deeppink']\n", | |
" \n", | |
" if (start != None) & (end != None):\n", | |
" data = data.loc[start : end, close_column].to_frame()\n", | |
" else:\n", | |
" data = data\n", | |
" \n", | |
" mpl.rcParams['font.family'] = 'monospace'\n", | |
" fig, ax = plt.subplots(facecolor = OUTTER_BACK, figsize = (13, 7))\n", | |
" plt.style.use(\"ggplot\");\n", | |
" ax.plot(data, color = random.choice(colors))\n", | |
" ax.set_facecolor(INNER_BACK)\n", | |
" ax.grid(color=FOREGROUND, linestyle=':', linewidth=0.65, alpha = 1)\n", | |
"\n", | |
" plt.tick_params(labelrotation = 40);\n", | |
" plt.title(title, fontsize = 23, pad = 20, color=\"white\");\n", | |
" plt.ylabel(ylabel, fontsize = 18, color=FOREGROUND);\n", | |
" plt.xlabel(xlabel, fontsize = 18, color=FOREGROUND);\n", | |
" plt.xticks(fontsize=12, color=\"white\")\n", | |
" plt.yticks(fontsize=12, color=\"white\")\n", | |
" \n", | |
" print_date_range(data)\n", | |
" print(\"\")" | |
] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment