필터 지우기
필터 지우기

Heatmap on 1d-time series data

조회 수: 7 (최근 30일)
Robin Schäfer
Robin Schäfer 2020년 2월 8일
댓글: Robin Schäfer 2020년 2월 8일
Hello community,
i got several events on a 1-dimensional double Vector (about 60.000 x 1) (like a logical vector).
VecEvents=[0 0 0 1 0 1 0 1 1 0 1 0 0]; % 60.000x1 double
I extracted the timepoints the events occured and plotted them on a horizontal line to mark events:
Events=find(VecEvents==1);
y=ones(length(Events),1));
scatter(Events,y);
Here is an example of my real data:
Scatter.png
What I want is something like a coloured line or bar which highlights density of events.
My first approach was to smooth the vector linearly by a moving mean:
SmoothedEvents=movmean(Events,600);
So, this is not a solution, but if I plot my averaged vector against the time it will look like this:
t=1:length(SmoothedEvents); % I used a different vector for x-axis in the plot underneath
plot(t,SmoothedEvents);
movmean.png
Does anyone have a suggestion how to create a 1-dimensional heatmap (or something similar - see above) from my data? Is there even a better approach than averaging the vector?

채택된 답변

KSSV
KSSV 2020년 2월 8일
YOu can use somehting linke this:
x = 0:.05:2*pi;
y = sin(x);
z = zeros(size(x));
col = x; % This is the color, vary with x in this case.
surface([x;x],[y;y],[z;z],[col;col],...
'facecol','no',...
'edgecol','interp',...
'linew',5);
colorbar
  댓글 수: 1
Robin Schäfer
Robin Schäfer 2020년 2월 8일
Thank you, KSSV! Took me a while to understand 'surface' function but it works just the way i wanted (with adjusted movmean):
colorbar.png
I am not really sure if averaging is mathematically the right approach to highlight density....

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by