【问题标题】:Matplolib plot: Increase the size of data pointsMatplotlib plot:增加数据点的大小
【发布时间】:2022-01-25 23:25:16
【问题描述】:

我正在尝试绘制 numpy 数组 x_trainy_train。我正在使用 matplotlib 的 plot 函数,我想传递一个参数来增加数据点的大小。这是我的代码:

x_train = np.array([0.        , 0.10526316, 0.21052632, 0.31578947, 0.42105263,
       0.52631579, 0.63157895, 0.73684211, 0.84210526, 0.94736842,
       1.05263158, 1.15789474, 1.26315789, 1.36842105, 1.47368421,
       1.57894737, 1.68421053, 1.78947368, 1.89473684, 2.        ])

y_train = np.array([0.2260415, 0.08966768, -0.02649684, -0.1024971,   0.14580953, 
0.03593453, 0.14398569,  0.30298584,  0.51058752,  0.43602841,  0.50852418,
  1.05403315, 1.27155675,  1.38071476,  1.62995731,  1.6434204,   1.64367346,
  1.54763514, 1.47964281,  0.97544995])

plt.figure(figsize=(20,10))

plt.plot(x_train, y_train, '*', color='black', label='Train values with noise')

【问题讨论】:

    标签: python matplotlib plot


    【解决方案1】:

    使用markersize(快捷方式:ms):

    plt.plot(x_train, y_train, '*', color='black', label='Train values with noise', ms=12)
    

    【讨论】:

      【解决方案2】:

      使用 'markersize' 作为点的大小,如示例:

      plt.plot(x_train, y_train, '*', color='black', label='Train values with noise', markersize = 20)
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-09-01
        • 1970-01-01
        • 1970-01-01
        • 2013-02-04
        • 2023-02-12
        • 2020-04-13
        • 2018-09-22
        • 2018-05-26
        相关资源
        最近更新 更多