有没有办法在 Matplotlib 中制作具有数组大小的时间序列散点图?

Is there any way to make a timeseries scatterplot with array sizing in Matplotlib?

我正在尝试用 Pandas DataFrame 中的时间序列数据制作散点图。我想让标记的大小与数组中的值成比例。

matplotlib.pyplot.plot_date(x, y) 将不起作用,因为它不接受标记大小参数。

当我尝试使用 plt.scatter 时,它 returns 出现 invalid type promotion 错误。

是否有任何值得尝试的替代方案?

鉴于此 df:

import matplotlib.pyplot as plt
import pandas as pd
df = {'col1': ['2017-12-01','2017-12-02','2017-12-03', '2017-12-04'],
      'col2': [5,10,20,30]}
df = pd.DataFrame(data=df)
df['col1'] = pd.to_datetime(df['col1'], format='%Y-%m-%d')
x = df['col1']
y = df['col2']
print df
         col1  col2
0  2017-12-01     5
1  2017-12-02    10
2  2017-12-03    20
3  2017-12-04    30

和这个数组:

a =[1,5,10,20]

你可以试试:

for index, i in enumerate(a):
    plt.plot(df.iloc[index][0], df.iloc[index][1], marker='.', linestyle='None', markersize=i*2, color='r')
plt.show()