├── matplotlib ├── 2-stacked-bar.py ├── 1-simple-plot.py └── 3-barchart.ipynb └── .gitignore /matplotlib/2-stacked-bar.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import matplotlib.pyplot as plt 3 | 4 | N = 5 5 | men_means = (20, 35, 30, 35, 27) 6 | women_means = (25, 32, 34, 20, 25) 7 | men_std = (2, 3, 4, 1, 2) 8 | women_std = (3, 5, 2, 3, 3) 9 | 10 | # The x locations for the groups 11 | ind = np.arange(N) 12 | 13 | # Width of the bars: can also be len(x) sequence 14 | width = 0.35 15 | 16 | p1 = plt.bar(ind, men_means, width, yerr=menStd) 17 | p2 = plt.bar(ind, women_means, width, 18 | bottom=men_means, yerr=women_std) 19 | 20 | plt.ylabel('Scores') 21 | plt.title('Scores by group and gender') 22 | plt.xticks(ind, ('G1', 'G2', 'G3', 'G4', 'G5')) 23 | plt.yticks(np.arange(0, 81, 10)) 24 | plt.legend((p1[0], p2[0]), ('Men', 'Women')) 25 | 26 | plt.show() 27 | -------------------------------------------------------------------------------- /matplotlib/1-simple-plot.py: -------------------------------------------------------------------------------- 1 | ''' In this quick and sweet example you will find out about matplotlib basic functions 2 | to create a sample plot which shows your curiosity in learning matplotlib. 3 | Read along and have fun!''' 4 | 5 | import matplotlib 6 | import matplotlib.pyplot as plt # Pyplot is a rich collection of command style functions 7 | import numpy as np 8 | 9 | # Insert some data to play with below using Numpy 10 | t = np.arange(0.0, 2.0, 0.01) 11 | 12 | # Trigonometric sine 13 | s = 1 + np.sin(6 * np.pi * t) 14 | 15 | fix, ax = plt.subplots() 16 | 17 | # Make sure you plot the data indicated 18 | ax.plot(t, s) 19 | 20 | # Add some labels for x and y axes 21 | ax.set(xlabel='time (s)', ylabel='interest (points)', 22 | title='Your interest in Matplotlib ') 23 | 24 | # Add a marvelous grid 25 | ax.grid() 26 | 27 | # This function shows everything you've added so far in your plot. Enjoy the curvies! 28 | plt.show() 29 | -------------------------------------------------------------------------------- /matplotlib/3-barchart.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Barchart\n", 8 | "\n", 9 | "### A bar plot with errorbars and height labels on individual bars." 10 | ] 11 | }, 12 | { 13 | "cell_type": "code", 14 | "execution_count": null, 15 | "metadata": {}, 16 | "outputs": [], 17 | "source": [ 18 | "import numpy as np\n", 19 | "import matplotlib.pyplot as plt\n", 20 | "\n", 21 | "men_means, men_std = (20, 35, 30, 35, 27), (2, 3, 4, 1, 2)\n", 22 | "women_means, women std (25, 32, 34, 20, 25), (3, 5, 2, 3, 3)\n", 23 | "\n", 24 | "# The x locations for the groups\n", 25 | "ind = np.arrange(len(men_means))\n", 26 | "\n", 27 | "# The width of the bars\n", 28 | "width = 0.35" 29 | ] 30 | } 31 | ], 32 | "metadata": { 33 | "kernelspec": { 34 | "display_name": "Python 3", 35 | "language": "python", 36 | "name": "python3" 37 | }, 38 | "language_info": { 39 | "codemirror_mode": { 40 | "name": "ipython", 41 | "version": 3 42 | }, 43 | "file_extension": ".py", 44 | "mimetype": "text/x-python", 45 | "name": "python", 46 | "nbconvert_exporter": "python", 47 | "pygments_lexer": "ipython3", 48 | "version": "3.6.8" 49 | } 50 | }, 51 | "nbformat": 4, 52 | "nbformat_minor": 2 53 | } 54 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | MANIFEST 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | .pytest_cache/ 49 | 50 | # Translations 51 | *.mo 52 | *.pot 53 | 54 | # Django stuff: 55 | *.log 56 | local_settings.py 57 | db.sqlite3 58 | 59 | # Flask stuff: 60 | instance/ 61 | .webassets-cache 62 | 63 | # Scrapy stuff: 64 | .scrapy 65 | 66 | # Sphinx documentation 67 | docs/_build/ 68 | 69 | # PyBuilder 70 | target/ 71 | 72 | # Jupyter Notebook 73 | .ipynb_checkpoints 74 | 75 | # pyenv 76 | .python-version 77 | 78 | # celery beat schedule file 79 | celerybeat-schedule 80 | 81 | # SageMath parsed files 82 | *.sage.py 83 | 84 | # Environments 85 | .env 86 | .venv 87 | env/ 88 | venv/ 89 | ENV/ 90 | env.bak/ 91 | venv.bak/ 92 | 93 | # Spyder project settings 94 | .spyderproject 95 | .spyproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | # mkdocs documentation 101 | /site 102 | 103 | # mypy 104 | .mypy_cache/ 105 | --------------------------------------------------------------------------------