0

I have 3 column data in large text file which each column contains 1d array. first column (x) is time as datetime format, second column (y) is frequency and third column (z) is Power in dB. Here is the example data.

    x (datetime)           y(freq(hz)) z(power(dB))
2017-10-03 14:23:14.787976 80000000.0 3.410517462
2017-10-03 14:23:14.788147 80006250.0 3.74720499199 
2017-10-03 14:23:14.788245 80012500.0 3.48457072216 
2017-10-03 14:23:14.788334 80018750.0 3.82477967161 
2017-10-03 14:23:14.788423 80025000.0 4.10110487733

I would like to plot these data to spectrogram using matplotlib contour with time(x) as x axis, freq as y axis and power as contour. I've mesh x and y as coordinat with np.meshgrid but z is still 1d array, it seem like 1d array format doesn't support to plot with contour. Should i convert z into 2d array? If so, how do i turn z into 2d array?

Sinta
  • 1
  • Your data does not seem to allow for a 2D representation. You have one y and one z value per x, hence you may plot y(x) and z(x). But in order to plot z(x,y) you would need x and y to actaully already denote some values on a grid - which doesn't seem to be the case here. Two suggestions. First, plot `plt.scatter(x,y, c=z)` and see how that looks, possibly share that plot here. If this does not produce a line of points, plot `plt.tricontourf(x,y,z)`. – ImportanceOfBeingErnest Oct 13 '17 at 08:33
  • Possible duplicate of https://stackoverflow.com/questions/42702920/plotting-isolines-contours-in-matplotlib-from-x-y-z-data-set Although it is not clear from the question whether the data allows for that. One could also close the question as too broad or off-topic (without reproducible problem). – ImportanceOfBeingErnest Oct 13 '17 at 08:44

0 Answers0