so i am trying to plot a uniform distribution using scipy.stats, but am running into this error, to do with shape transformation, could someone please tell me why this is happening / how my code should look, thank you.
Full Code and traceback below:
# UNIFORM DISTRIBUTION:
from scipy.stats import uniform
import matplotlib.pyplot as plt
fig, ax = plt.subplots(1, 1)
n = 10 # total data number
x = list(range(0, n + 1))
# create a list of values that follow uniform distribution
r = uniform.rvs(size=1000)
ax.vlines(x, 0, r, colors = "blue")
plt.show()
FULL TRACEBACK:
ValueError Traceback (most recent call last) in 12 # create a list of values that follow uniform distribution 13 r = uniform.rvs(size=1000) ---> 14 ax.vlines(x, 0, r, colors = "blue") 15 plt.show() 16
\matplotlib_init_.py in inner(ax, data, *args, **kwargs) 1436 def inner(ax, *args, data=None, **kwargs): 1437 if data is None: -> 1438 return func(ax, *map(sanitize_sequence, args), **kwargs) 1439 1440 bound = new_sig.bind(ax, *args, **kwargs)
\matplotlib\axes_axes.py in vlines(self, x, ymin, ymax, colors, linestyles, label, **kwargs)
1257 masked_verts[:, 0, 1] = ymin 1258
masked_verts[:, 1, 0] = x -> 1259 masked_verts[:, 1, 1] = ymax 1260 1261 lines = mcoll.LineCollection(masked_verts, colors=colors,\numpy\ma\core.py in setitem(self, indx, value) 3378 if _mask is nomask: 3379 # Set the data, then the mask -> 3380 _data[indx] = dval 3381 if mval is not nomask: 3382 _mask = self._mask = make_mask_none(self.shape, _dtype)
ValueError: could not broadcast input array from shape (1000) into shape (11)