Matlab代码实现绘制趋势图

2021年美赛A题趋势图绘制Matlab代码实现

clearvars; clc; % decomposition_rate_trend
target_path = 'D:\SJTU大三(上)总\杂项\科研项目\2021MCM\regulation_test\figures\tendency_chart\matlab_fig\DR_tendency_chart.png';
decomposition_rate_data_mat = importdata('D:\SJTU大三(上)总\杂项\科研项目\2021MCM\regulation_test\data\raw data\xlsx format\Diversity.xlsx');
decomposition_rate_data_mat = decomposition_rate_data_mat.data;
time_series = decomposition_rate_data_mat(:, 1);
a_type_rate = decomposition_rate_data_mat(:, 2);
o_type_rate = decomposition_rate_data_mat(:, 3);
as_type_rate = decomposition_rate_data_mat(:, 4);
aos_type_rate = decomposition_rate_data_mat(:, 5);
clear decomposition_rate_data_mat;
figure(1);
set(gca, 'xlim', [0, 360]); hold on;
plot(time_series, a_type_rate, 'LineWidth', 1); hold on;
plot(time_series, o_type_rate, 'LineWidth', 1); hold on;
plot(time_series, as_type_rate, 'LineWidth', 1); hold on;
plot(time_series, aos_type_rate, 'LineWidth', 1); hold on;
clear a_type_rate o_type_rate as_type_rate aos_type_rate;
grid on;
legend('Type-A', 'Type-O', 'Type-AS', 'Type-AOS');
xlabel('Days', 'FontSize', 15); ylabel('DR', 'FontSize', 15); title('Tendency Chart of DR', 'FontSize', 13);

saveas(gcf, target_path); clear target_path; close all;

效果图

Matlab代码实现绘制趋势图_第1张图片

 

你可能感兴趣的:(matlab,开发语言)