0

I have the following

a = np.arange(1000)
b = np.arange(100)

I want to plot both a and b on the same plot, with all points from a appearing, and for each point of b, have 10 points show up, with no interpolation. b point values should change every 10 samples from a, and they should be synchronized such that a[::10] corresponds to b[:].

Plotting with .plot() is fine, no need for scatter().


Can this be done with pure matplotlib? If not, how to do it with numpy?

Gulzar
  • 23,452
  • 27
  • 113
  • 201
  • I'd just use np.repeat: https://numpy.org/doc/stable/reference/generated/numpy.repeat.html#numpy.repeat – Jody Klymak May 10 '21 at 14:32
  • Solution here: `ax.plot(a); ax.step(b * 10, b, where='post')` Dup is correct. – Gulzar May 10 '21 at 15:03
  • np.repeat is incorrect, as it creates point data instead of just displaying vector data. It will be very slow in many cases. – Gulzar May 24 '21 at 09:07

0 Answers0