tomzko tomzko - 1 year ago 125
Python Question

Plot or reshape 2D array matplotlib

i have no idea how can i plot scatter with a 2D array of this type:


the plot should be x vs t, maybe instead of doing this with a maplotlib routine be able to reshape a to obtain:



Answer Source

Assuming your data starts in the format a = [[x0, t0]]:

Split x & t into separate lists, then you can pass them into matplotlib.

import matplotlib.pyplot as plt
x = [i[0] for i in a]
t = [i[1] for i in a]
plt.plot(x, t)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download