0

using matplotlib, I have constructed a boxplot for a dataset read from excel. I want to include the individual data points alongside my boxplot. Any advice? Here is the code I used for my boxplot:

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns

Fast_G = pd.read_excel(r'C:\Users\Rex Reginald\Excel work\MFGP.xlsx')
plt.style.use('ggplot')

fig, ax = plt.subplots()

ax.boxplot((Fast_G.MIA, Fast_G.CTL), vert=True, showmeans=True, meanline=True, patch_artist=True,
           labels=('MIA', 'CTL'),
           medianprops={'linewidth': 2, 'color': 'purple'},
           meanprops={'linewidth': 2, 'color': 'red'})

plt.title('MFGP')
plt.ylabel('MP')

plt.show()
Rex Reginald
  • 31
  • 1
  • 2
  • Use `seaborn.boxplot` and then add a [`seaborn.stripplot`](https://seaborn.pydata.org/generated/seaborn.stripplot.html) or `seaborn.swarmplot` to the same figure. `seaborn` is a high-level API for `matplotlib`. – Trenton McKinney Mar 15 '21 at 19:15
  • Always provide a complete [mre] with code, **data, errors, current output, and expected output**, as **[formatted text](https://stackoverflow.com/help/formatting)**. If relevant, only plot images are okay. Please see [How to ask a good question](https://stackoverflow.com/help/how-to-ask). Provide data with [How to provide a reproducible copy of your DataFrame using `df.head(15).to_clipboard(sep=',')`](https://stackoverflow.com/q/52413246/7758804), then **[edit] your question**, and paste the clipboard into a code block. – Trenton McKinney Mar 15 '21 at 19:22

0 Answers0