필터 지우기
필터 지우기

Vertical bars in scatter plot

조회 수: 4 (최근 30일)
Anouk Heuvelmans
Anouk Heuvelmans 2023년 1월 2일
댓글: Anouk Heuvelmans 2023년 1월 3일
Hi everyone,
I have a scatterplot with points on 12 horizontal lines. Sometimes, the points synchronize and in this case, I want to put a semi-transparant black bar in the background, spanning the period of overlap.
The data for my scatterplot is in a matrix with [y,x]. The data for the synchronization is in a matrix with [x,duration of the synchronized period].
I was wondering if, and how, it would be possible to create a grey bar in the background of the scatterplot. I've added an example of the scatterplot without bar below, and have in one of the synchronized events made a grey bar as I mean to have it in powerpoint.
This is the code for my scatter plot:
figure();
scatter(peaktrains(:,2)./1000000,peaktrains(:,1),"|",'MarkerEdgeColor','#097F97')

채택된 답변

Cameron
Cameron 2023년 1월 2일
x = randi([200 800],800,1); %random x data for scatter
y = randi([1 12],800,1); %random y data for scatter
scatter(x,y,'b')
hold on
barx = [475,475,490,490]; %bar x data
bary = [0,12,12,0]; %bar y data
fill(barx,bary,[0.95,0.95,0.95],'FaceAlpha',0.3)
hold off
  댓글 수: 1
Anouk Heuvelmans
Anouk Heuvelmans 2023년 1월 3일
Thanks a lot Cameron!! That helped.

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by