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?

3
  • I'd just use np.repeat: numpy.org/doc/stable/reference/generated/… Commented May 10, 2021 at 14:32
  • Solution here: ax.plot(a); ax.step(b * 10, b, where='post') Dup is correct. Commented May 10, 2021 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. Commented May 24, 2021 at 9:07

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.