o1-preview-2024-09-12· OpenAI
WildChat-4.8M (AI2)
基于matlab 画学术化折线图 一共六条折线
- User
基于matlab 画学术化折线图 一共六条折线
- Assistant
以下是在 MATLAB 中绘制六条折线的学术化折线图的示例代码:
% 生成示例数据 x = linspace(0, 10, 100); y1 = sin(x); y2 = cos(x); y3 = sin(2*x); y4 = cos(2*x); y5 = sin(0.5*x); y6 = cos(0.5*x); % 创建图形 figure; % 绘制六条折线 plot(x, y1, '-o', 'LineWidth', 1.5, 'MarkerIndices', 1:10:length(x)); hold on; plot(x, y2, '--s', 'LineWidth', 1.5, 'MarkerIndices', 1:10:length(x)); plot(x, y3, ':d', 'LineWidth', 1.5, 'MarkerIndices', 1:10:length(x)); plot(x, y4, '-.^', 'LineWidth', 1.5, 'MarkerIndices', 1:10:length(x)); plot(x, y5, '--v', 'LineWidth', 1.5, 'MarkerIndices', 1:10:length(x)); plot(x, y6, ':x', 'LineWidth', 1.5, 'MarkerIndices', 1:10:length(x)); hold off; % 设置图例 legend({'sin(x)', 'cos(x)', 'sin(2x)', 'cos(2x)', 'sin(0.5x)', 'cos(0.5x)'}, 'Location', 'best'); % 添加标题和坐标轴标签 title('学术化折线图示例', 'FontSize', 14, 'FontWeight', 'bold'); xlabel('X 轴', 'FontSize', 12); ylabel('Y 轴', 'FontSize', 12); % 美化图形 grid on; set(gca, 'FontSize', 12); % 设置刻度字号 set(gca, 'LineWidth', 1); % 设置坐标轴线宽 box on; % 显示边框 % 调整图形大小 set(gcf, 'Position', [100, 100, 800, 600]);