How to insert bar markers in a line plot

조회 수: 6 (최근 30일)
Aaron Ouyang
Aaron Ouyang 2022년 7월 11일
답변: Aaron Ouyang 2022년 7월 12일
Hi,
I've been plotting a line graph of a cell's response to different chemicals administered at different times. The dataset is a 1470x1 double. I ran this code to generate a graph:
load(data)
t = linspace(0,length(data)*2, length(data)); % create a vector specifying the data to use for the x axis. i need to adjust the axis because the data was collected in a different timeframe
plot(t, data);
I want to be able to show the names of the compounds injected with text labels and I also want to have bars underneath the line plot that indicate when a stimulus was injected and for how long (i.e. at 1500 seconds Compound 8 was injected for 20 seconds). I drew a picture to illustrate my idea:
Does anyone know how I can make this happen? Thank you.
  댓글 수: 2
dpb
dpb 2022년 7월 11일
Use patch with a column for each compound x,y coordinates; and text to write the labels.
I'm too lazy to make up the data to illustrate but shouldn't be difficult at all.
Aaron Ouyang
Aaron Ouyang 2022년 7월 12일
Got it, thank you so much.

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

채택된 답변

Aaron Ouyang
Aaron Ouyang 2022년 7월 12일
See dpb comment

추가 답변 (0개)

카테고리

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

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by