I am trying to plot a regression fit plot with scatter values and regression fit.
Attached is the excel file with data from dropbox and the desired output graph (made in sigmaplot) https://www.dropbox.com/s/czwq78yyy6vymaj/aniso.xlsx?dl=0
My code:
import matplotlib.pyplot as plt
import pandas as pd
data_x = pd.read_excel('aniso.xlsx', 'Sheet1', parse_cols='B', skiprows=2)
data_36 = pd.read_excel('aniso.xlsx', 'Sheet1', parse_cols='H', skiprows=2)
data_37 = pd.read_excel('aniso.xlsx', 'Sheet1', parse_cols='N')
data_38 = pd.read_excel('aniso.xlsx', 'Sheet1', parse_cols='O')
data_39 = pd.read_excel('aniso.xlsx', 'Sheet1', parse_cols='A')
plt.plot(data_x[2:21], data_36[2:21], 'h', color='#1f77b4', label='protein concentration')
plt.plot(data_37, data_38, color='#d62728', ls='--', label='regression fit')
plt.errorbar(data_x[2:21], data_36[2:21], yerr=data_39[2:21])
plt.show()
When running this code, I get the following error:
File "/usr/local/lib/python2.7/site-packages/matplotlib/axes/_axes.py", line 2931, in xywhere
assert len(xs) == len(ys)
AssertionError

errorbarcall, not for instance from the secondplot(you don't use slicing there)? Can you post the entire error trace, not just the last line?skiprows. Try printing outdata_x,data_36anddata_39. You'll see that they're different lengths, and that the headers are being read in incorrectly. Also note that because column B has a 2-line header, it will need to be read in differently to the other columns with only 1-line headers. Also, if youskiprowswhen you read the data in, you probably don't need to also slice the data between[2:21], since the skiprows should take care of removing the items at the start. I haven't added this as an answer since I haven't tested it out.data_39 = pd.read_excel('aniso.xlsx', 'Sheet1', parse_cols='A')