Home > Software design >  Matplolib plot: Increase the size of data points
Matplolib plot: Increase the size of data points

Time:12-27

I am trying to plot the numpy arrays x_train and y_train. I am using matplotlib's plot function and I would like to pass an argument to increase the size of the data points. Here is my code:

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')

enter image description here

CodePudding user response:

Use markersize (shortcut: ms):

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

enter image description here

CodePudding user response:

Use 'markersize' as the size of the points, as in the example:

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