如何将'markersize'参数添加到DataFrame图中?

时间:2019-03-27 00:22:46

标签: python matplotlib plot

我正在尝试绘制一个DataFrame,我想修改markersize,但是似乎无法在同一plot()调用中完成它。

// get customers
db.getCollection('customers').aggregate([{
  $graphLookup: {
    from: "customers",
    startWith: "$dependencies.customers",
    connectFromField: "dependencies.customers",
    connectToField: "_id",
    depthField: "depth",
    as: "dependencies.customers",
    maxDepth: 5,
  }
}])


// get customersOf (reverse direction)
db.getCollection('customers').aggregate([{
  $graphLookup: {
    from: "customers",
    startWith: "$dependencies.customersOf",
    connectFromField: "dependencies.customersOf",
    connectToField: "_id",
    depthField: "depth",
    as: "dependencies.customersOf",
    maxDepth: 5,
  }
}])

我遇到错误:AttributeError:未知属性标记大小。

但是,似乎允许使用'markersize'(https://matplotlib.org/api/_as_gen/matplotlib.pyplot.plot.html),所以我不确定是什么问题。

1 个答案:

答案 0 :(得分:0)

使用scatter plot,您的size参数仅为s,请尝试:

ax0 = df_can_t.plot(kind='scatter', x='Year', y='China', \
figsize=(30,10), color = 'red', marker= '+', s = 14.0)

这是MVCE:

import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

df = sns.load_dataset('iris')

ax = df.plot(kind='scatter', x='petal_width', y='sepal_width', s=10.0)

输出:

enter image description here