{ "cells": [ { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "Plotting with Matplotlib\n", "========================\n", "\n", "``````{admonition} Overview\n", ":class: overview\n", "\n", "Questions:\n", "\n", "* How can I create plots using matplotlib?\n", "\n", "Objectives:\n", "\n", "* Use pandas built-in plotting.\n", "\n", "* Use matplotlib's object oriented interface to make figures with subplots.\n", "\n", "``````\n", "\n", "Matplotlib is among the oldest and most widely used plotting libraries in Python. \n", "Some plotting libraries, such as seaborn, are built-in top of Matplotlib. Matplotlib is very flexible and customizable. \n", "\n", "In this section, we will see how three ways we can use matplotlib to create plots. \n", "The most customizable interface is the object oriented interface. \n", "Learning to use matplotlib will allow you to make beautiful, publication-quality plots and will help you more effectively use libraries which interface with matplotlib.\n", "\n", "We'll start by reading in the same data file we've been using for this session. We'll look at the visualization built in the pandas dataframe, then discuss making custom visualizations with matplotlib." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import pandas as pd" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | Compound ID | \n", "ESOL solubility (mol/L) | \n", "Minimum Degree | \n", "Molecular Weight | \n", "Number of H-Bond Donors | \n", "Number of Rings | \n", "Number of Rotatable Bonds | \n", "Polar Surface Area | \n", "measured solubility (mol/L) | \n", "smiles | \n", "
---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "Amigdalin | \n", "-0.974 | \n", "1 | \n", "457.432 | \n", "7 | \n", "3 | \n", "7 | \n", "202.32 | \n", "-0.77 | \n", "OCC3OC(OCC2OC(OC(C#N)c1ccccc1)C(O)C(O)C2O)C(O)... | \n", "
1 | \n", "Fenfuram | \n", "-2.885 | \n", "1 | \n", "201.225 | \n", "1 | \n", "2 | \n", "2 | \n", "42.24 | \n", "-3.30 | \n", "Cc1occc1C(=O)Nc2ccccc2 | \n", "
2 | \n", "citral | \n", "-2.579 | \n", "1 | \n", "152.237 | \n", "0 | \n", "0 | \n", "4 | \n", "17.07 | \n", "-2.06 | \n", "CC(C)=CCCC(C)=CC(=O) | \n", "
3 | \n", "Picene | \n", "-6.618 | \n", "2 | \n", "278.354 | \n", "0 | \n", "5 | \n", "0 | \n", "0.00 | \n", "-7.87 | \n", "c1ccc2c(c1)ccc3c2ccc4c5ccccc5ccc43 | \n", "
4 | \n", "Thiophene | \n", "-2.232 | \n", "2 | \n", "84.143 | \n", "0 | \n", "1 | \n", "0 | \n", "0.00 | \n", "-1.33 | \n", "c1ccsc1 | \n", "