如何使用matplotlib python区分x轴上两列的颜色值?
我试图做一个在x轴上有日期,在y轴上有一些值的绘图。但我有两列作为日期。我想用另一种颜色的点突出第二栏的日期。可能吗如何使用matplotlib python区分x轴上两列的颜色值?,python,matplotlib,seaborn,Python,Matplotlib,Seaborn,我试图做一个在x轴上有日期,在y轴上有一些值的绘图。但我有两列作为日期。我想用另一种颜色的点突出第二栏的日期。可能吗 |---------------------|------------------|------------------|------------------| |ID | Date1 | Date2 |值| |---------------------|------------------|------------------|------------------| |
|---------------------|------------------|------------------|------------------|
|ID | Date1 | Date2 |值|
|---------------------|------------------|------------------|------------------|
| 1 | 2008-05-14 | 2010-03-28 | 5 |
|---------------------|------------------|------------------|------------------|
| 1 | 2005-12-07 | 2010-03-28 | 3 |
|---------------------|------------------|------------------|------------------|
| 1 | 2008-10-27 | 2010-03-28 | 6 |
那么ax.plot(chol2['Date2'],chol2['value'],'o-',color='green')呢??是的,听起来不错。如果我想在Date2绘制一条垂直线呢?
ax.axvline(df1['Date2'][0])
?非常好,谢谢!!
df1 = df[df['ID']== 1]
df1= df1.sort_values(by='Date1')
date = df1['Date1']
res = df1['values']
fig, ax = plt.subplots()
ax.plot(date, res, 'o-')