MATLAB Answers

How To Create A Persistence Plot

40 ビュー (過去 30 日間)
DrEamonn
DrEamonn 2020 年 8 月 9 日
コメント済み: Star Strider 2020 年 8 月 11 日
I have quite a large data set that I want to visulaise by overlaying all the traces on one plot, with the traces only using one colour & the opacity/brightness of the resulting trace determined by how many instances of a particular value occur at each point - the only thing I can think to compare it to would be persistence on an old school oscilloscope.
Can someone point me to the correct plot type to achieve this or help me out with some code?
Thanks

  5 件のコメント

表示 2 件の古いコメント
Adam Danz
Adam Danz 2020 年 8 月 10 日
An example image would help.
It sounds like you have you have to compute the outter boundaries of the data and then use patch or fill to plot the shape of the data.
DrEamonn
DrEamonn 2020 年 8 月 10 日
This is similar to what I had in mind.
The main difference between the above & what I would like to achieve is that I would like the opacity to vary depending on denisty of values i.e. simialr to an old school oscilloscope display with persistence.
Adam Danz
Adam Danz 2020 年 8 月 10 日
As far as I know you cannot vary the transparency within a patch. However, you can adjust the color (ie, shades of blue) and then set a constant transparency value.
Here's some background info on controlling the color transitions of a patch by setting the CData property of a patch object. You can set a colormap from light blue to dark blue.

サインインしてコメントする。

採用された回答

Star Strider
Star Strider 2020 年 8 月 10 日
Perhaps something like this:
x = linspace(0, 10, 250); % Create Data
y = randn(10,1) .* sin(2*pi*x + randn(10,1)); % Create Data
figure
plot(x, y) % Original Waveforms
grid
colMin = min(y);
colMax = max(y);
colMean = mean(y);
figure
plot(x, colMean) % Data Mean
hold on
patch([x fliplr(x)], [colMin fliplr(colMax)], 'b', 'FaceAlpha',0.2, 'EdgeColor','none') % Shaded Range
hold off
grid
producing:
This can likely be changed to show other results.
.

  10 件のコメント

表示 7 件の古いコメント
dpb
dpb 2020 年 8 月 10 日
Ah. If "wasn't obvious" to you, then it certainly isn't to me! I never could much fathom CData anyways; just thought perhaps you hadn't thought to look--but, that is also not a likely event either. :)
DrEamonn
DrEamonn 2020 年 8 月 11 日
I have run some experiements & have a question:
The first plot shows the data plotted using 'plot()'
The second shows the same data plotted using the Start Strider's code:
Why is the highest value on the second plot higher than the first if it is plotted using the same data?
Star Strider
Star Strider 2020 年 8 月 11 日
Why is the highest value on the second plot higher than the first if it is plotted using the same data?
My code creates the gradients with reference to the standard deviations of the data, going from -3 to +3, corresponding to probabilities of the data being in that range of 0.0013499 to 0.9986501, so a probability of 0.005 that the data will be included within those limits. If you prefer that they have different limits, set ‘stdMult’ to a different range, perhaps using linspace:
stdMult = linspace(-2, 2, 15);
The limits must be symmetrical, and an odd number of elements appears to work best. You can experiment with and design the probabilities using normcdf (that will produce the associated probabilities from the elements of ‘stdMult’) and norminv (that will produce the limits for ‘stdMult’ from the chosen probability).

サインインしてコメントする。

その他の回答 (0 件)

製品


リリース

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by