Hello! I created a scatter plot with maximum temperatures and daily data from the 1930s to 2020. I want to create a straight line in the 100F (for high temperature reference) in my y axis but I can't. I tried many codes from Matworks but no success.
Hope anyone can help me with this.
This is the plot I get and the code I used
figure('Name','Daily TMAX');
hold on
scatter(Date,DailyTMAX,'b','*')

 채택된 답변

Cris LaPierre
Cris LaPierre 2021년 8월 29일

2 개 추천

Use yline.
scatter(rand(1,100),rand(1,100),'b','*')
yline(0.7)

추가 답변 (1개)

Chunru
Chunru 2021년 8월 29일

1 개 추천

Date = datetime([1930:2020], 1, 1);
DailyTMAX = randn(size(Date));
figure('Name','Daily TMAX');
hold on
scatter(Date,DailyTMAX,'b','*')
yline(max(DailyTMAX), 'r--')

댓글 수: 3

Nuria Andreu
Nuria Andreu 2021년 8월 29일
Thank you! Both answers worked
Cris LaPierre
Cris LaPierre 2021년 8월 29일
Just a comment that hold on is not necessary when using xline or yline. However, adding it has no adverse effect.
Also, it is best practice to always pair a hold on with a corresponding hold off.
Nuria Andreu
Nuria Andreu 2021년 8월 29일
Thank you Cris, I will practice more!

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

카테고리

도움말 센터File Exchange에서 Polar Plots에 대해 자세히 알아보기

제품

릴리스

R2021a

태그

질문:

2021년 8월 29일

댓글:

2021년 8월 29일

Community Treasure Hunt

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

Start Hunting!

Translated by