필터 지우기
필터 지우기

Add average temperature line onto plot

조회 수: 4 (최근 30일)
Abigail Waring
Abigail Waring 2021년 8월 4일
답변: Cris LaPierre 2021년 8월 4일
The following code is used to plot a t2m plot and i want to add a horizontal average temperature line but not sure how
any ideas?
% combined_ERA_data_new
%% Load in the data
data_1 = load('../data/ERA/ERA5_2_1979_1984.mat', 'data_to_save');
data_2 = load('../data/ERA/ERA5_2_1985_1990.mat', 'data_to_save');
data_3 = load('../data/ERA/ERA5_2_1991_2000.mat', 'data_to_save');
data_4 = load('../data/ERA/ERA5_2_2001_2010.mat', 'data_to_save');
data_5 = load('../data/ERA/ERA5_2_2011_2021.mat', 'data_to_save');
%% Combine data all
data_all = [data_1.data_to_save; data_2.data_to_save; data_3.data_to_save; data_4.data_to_save; data_5.data_to_save;];
%% Plot figure
disp('Plotting and saving a figure...');
% Make a figure
figure('units','normalized','outerposition',[0 0 1 1],'visible','on');
set(gcf,'color','w');
% Set axis font size
font_size = 12;
set(0, 'DefaultAxesFontSize', font_size);
% Plot
plot(data_all(:,1), data_all(:,2), '-r'); datetick('x')
%% Set plot details
ylabel ('T2M (degrees celcius)');
xlabel ('Time (years)');
title ('Reanalysis Dataset for T2M Data from 80.5N, to -58W, 1979-2021');
legend({'= T2M'},'Location','southwest');
ax = gca;
ax.FontSize = 14;

답변 (1개)

Cris LaPierre
Cris LaPierre 2021년 8월 4일
Use the yline function.

카테고리

Help CenterFile Exchange에서 Labels and Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by