matplotlib:散点图无法连接点

时间:2016-09-22 23:47:50

标签: python-2.7 pandas matplotlib

我使用以下代码绘制散点图,并尝试连接图中的点:

   %matplotlib notebook
    import matplotlib.pyplot as plt
    import matplotlib
    matplotlib.style.use('ggplot')
    my_df.plot(x='k', y='score', kind = 'scatter', marker = 'x', linestyle='-')

也尝试过:

    my_df.plot(x='k', y='score', kind = 'scatter', 'xb-')

但以上都没有。谁知道我错过了什么?谢谢!

2 个答案:

答案 0 :(得分:1)

更改marker kwag,然后移除kind kwag:

my_df.plot(x='k', y='score', marker='x-')
# removing linestyle is optional. It does not help in this case

答案 1 :(得分:0)

经过一些实验,下面的代码有效:

%matplotlib notebook
import matplotlib.pyplot as plt
import matplotlib
matplotlib.style.use('ggplot')
my_df.plot(x='k', y='score', marker = 'x', color = 'black')