Given the complexity of my data set, I gave up trying to figure this out. Instead I resampled the data so that the start and end y values are the same over a certain length determined by the depth values. Basically, I doubled my data length and y samples. It works and can handle the gaps in the data just fine.
Create stair plot with uneven spaced data?
11 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I guess I am over thinking this, but I can't seem to find a solution to my problem.
I have a several columns of variables that represent the mid points of two depths. The depths are not evenly spaced. Some represent 3cm, some 4, others 5 or even 5cm. I would like to create a stair step plot that will handle unevenly spaced depths. See image. Column 1 is my start depth, Column 2 my end depth. Column 3 is the variable to be plotted.
I looked at the stair function and this will create the plot I would like, but I haven't been able to figure out how to use it with user defined spacing that is also uneven.
using the stairs code,
figure; stairs(DepthCopy(1:100,1),DepthCopy(1:100,3))
I come up with this graph, however, the long line between 6 and 6.5 should be a gap as their is no data for this section. It handles the smaller gaps fine when there is a depth but no data, but not when there no depth and no data.
Is my only option to resample the data down to the smallest increment and fill in the fake gaps with NaN?
Any suggestions?
0 Commenti
Risposta accettata
Cg Gc
il 16 Gen 2019
2 Commenti
Walter Roberson
il 16 Gen 2019
It is possible without resampling. Unfortunately I was responding in the middle of my night, and it was escaping me as how best to do it in vectorized fashion, so I headed to bed...
Più risposte (1)
Walter Roberson
il 16 Gen 2019
When you use stairs() there is no requirement that the x values be evenly spaced.
Supposing your data is in DD:
stairs([DD(1:8,1),DD(8,2)],[DD(1:8,3),DD(8,3)])
hold on
stairs([DD(9:end,1),DD(end,2)],[DD(9:end,3),DD(end,3)])
hold off
You cannot do it as one continuous plot because the right edge of row 8 has a gap of 5 mm before the start of row 9.
3 Commenti
Walter Roberson
il 16 Gen 2019
where I used [DD(something ),DD(something )] use semicolon between the parts.
I pointed out the 5 mm gap and created a second plot to handle it since you were emphasising the importance of the irregularities . Is that gap in fact significant or can we assume that the sections are contiguous or is there some larger gap that is significant while 5mm is not?
Vedere anche
Categorie
Scopri di più su Annotations in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!