<jupyter_start><jupyter_text>Introduction to producing high quality plots in Python  Intended audience:* Academic Researchers* Students learning Python* Anyone who is interested.The code included in this notebook is published under an MIT license (**that means I want you to use it**)  Overview:Microsoft Excel is a common choice for researchers.  Excel can produce a range of plots - easily - that are useful during the lifetime of the study. However, Excel plots are often not suitable for Journal publication as the resolution of the charts it produces is below the typical **300dpi** requirement of academic publishers. It also makes reviewers grumpy. This tutorial aims to help researchers used to generating plots in Excel transition to using Python's `matplotlib` and `seaborn` modules.  There is a YouTube video to accompany this notebook: **Before getting started**    MatPlotLib is free and open source under and MIT license.  If you use it in a publication please could you appropriately cite it. https://matplotlib.org/citing.html  Importing Python ModulesThe modules you need for high quality plotting are `matplotlib` and `seaborn`It is not strictly necessary for plotting, but it is also recommended that `pandas` or `numpy` is used for importing data.  Data could be pre-processed prior to importing (in an external software such as Excel) or `pandas` or `numpy` could be used.  The use of `pandas` and `numpy` for pre-processing is out of scope of this tutorial.  A bit confusingly, `pandas` can also be used for plotting directly, but that builds largely on `matplotlib`<jupyter_code>import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns

#this means that plots will appear 'inline' in Jupyter
%matplotlib inline  
#I use seaborn as its gives a good default look to the charts
#It also has lots of useful charts available
sns.set()
#sns.set(style="whitegrid")<jupyter_output><empty_output><jupyter_text>Creating time series plots  Step 1: Import data into pandas<jupyter_code>df = pd.read_csv('data/admission_series.csv')
df.head()<jupyter_output><empty_output><jupyter_text>Step 2a. Plot the time series using seaborn<jupyter_code>ax = sns.lineplot(x = "time", y = "per_admit", hue = "group", data = df)
ax.set_ylabel("proportion admitted")
ax.set_xlabel("month")
plt.show()



#l = ax.get_legend_handles_labels()
#print(l)
fig, ax = plt.subplots()
ax.plot(t, s)

ax.set(xlabel='time (s)', ylabel='voltage (mV)',
       title='About as simple as it gets, folks')
ax.grid()

fig.savefig("test.png")
plt.show()
df_a = df.loc[df['group'] == 0]
df_b = df.loc[df['group'] == 1]

plt.subplot(211)
plt.plot(df_a['time'], df_a['per_admit'])
plt.subplot(212)
plt.plot(df_b['time'], df_b['per_admit'])
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09283154121863799, 'fraction_numerical': 0.004659498207885305, 'mean_word_length': 5.3144796380090495, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '625998', 'license': 'MIT', 'n_tokens_mistral': 885, 'n_tokens_neox': 829, 'n_words': 352, 'path': 'test.ipynb', 'repo_name': 'TomMonks/simple-binder-template', 'size': '2790'}