我想把它从一条回归线变成一条曲线。也要让线到达图表的任意一侧。这是我的密码:
import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
data = {'Days': [5, 10, 15, 20],
'Impact': [33.7561, 30.6281, 29.5748, 29.0482]
}
a = pd.DataFrame (data, columns = ['Days','Impact'])
print (a)
ax = sns.barplot(data=a, x='Days', y='Impact', color='lightblue' )
# put bars in background:
for c in ax.patches:
c.set_zorder(0)
# plot regplot with numbers 0,..,len(a) as x value
ax = sns.regplot(x=np.arange(0,len(a)), y=a['Impact'], marker="+")
sns.despine(offset=10, trim=False)
ax.set_ylabel("")
ax.set_xticklabels(['5', '10','15','20'])
plt.show()
或者,我更喜欢在matplotlib中以散点图而不是条形图的形式进行。下面是excel中的一个示例,但理想情况是使曲线至少稍微超出外部标记。
有人能帮忙吗?
暂无答案!
目前还没有任何答案,快来回答吧!