MATLAB 论文绘图规范标注

在MATLAB中进行绘图时,标注(annotation)是一个重要的功能,它可以用来添加文本、箭头、图形等对象来说明图形中的特定部分。论文出图需要规范,需要有对应的标题、图例、坐标轴信息等。

matlab 复制代码
clear
clc
close all
x = 0:0.1:10;
y1 = sin(x);
y2 = cox(x);

1.标题和标签

  • 使用 title 函数添加图表标题。
  • 使用 xlabel 和 ylabel 函数添加 x 轴和 y 轴的标签。
  • 使用 legend 函数添加图例,解释不同线条或数据系列的含义。
matlab 复制代码
title('Your Title');
xlabel('X Axis Label');
ylabel('Y Axis Label');
legend('Label 1', 'Label 2'); 

2.文本标注

  • 使用 text 函数添加文本标注。
  • 使用 annotation 函数添加更复杂的标注,如箭头、椭圆等。
matlab 复制代码
text(1, 0.5, 'Your Text', 'FontSize', 12);
annotation('arrow', [0.3, 0.1], [0.7, 0.8]);

3.数据标注

使用 text 函数或 annotation 函数将文本标注添加到图表中的特定数据点

matlab 复制代码
text(3, 0.5, 'Data Label', 'FontSize', 10);

4.图形标注

  • 使用 rectangle、line、arrow 等函数创建简单的几何图形。
  • 使用 annotation 函数添加更复杂的图形标注,如箭头、椭圆等。
matlab 复制代码
rectangle('Position', [1, 2, 1, 1], 'EdgeColor', 'r', 'LineWidth', 2);
annotation('arrow', [0.3, 0.1], [0.7, 0.8]);

5.标注样式

调整字体大小、颜色、样式以及标注框的线宽和颜色,以确保标注清晰可读

matlab 复制代码
text(1, 0.5, 'Your Text', 'FontSize', 12, 'Color', 'blue');
annotation('textbox', [0.3, 0.1, 0.5, 0.5], 'String', 'Your Text', 'EdgeColor', 'black');

6.位置和布局

根据需要将标注放置在图表中合适的位置,以便清晰展示数据和信息

matlab 复制代码
% 设置标注文本的位置
x = 0.5;
y = 0.5;
% 添加标注文本
text(x, y, 'Your Text', 'FontSize', 12);

7.注释格式

使用标准的文本格式,如斜体、粗体、下标、上标等,以使标注更具可读性和美观性。

matlab 复制代码
text(x, y, '\bf{Bold Text} \it{Italic Text} \fontsize{12} Text', 'FontSize', 12);

8.以Latex解译方式的数学变量和公式的图形标注

对需要展示的变量或公式,用键盘美元符$符号包含,即$f(x)=sin and cos$,然后在图题(title)、坐标轴标注(XLabel\YLabel)、刻度(XTike/YTike)等代码行中添加

matlab 复制代码
title('$f(x)=sin and cos$','Interpreter','Latex')

9.坐标轴修饰

matlab 复制代码
ax = gca; hold on; box on
ax.XGrid = 'on';
ax.YGrid = 'on';
ax.XMinorTick = 'on';
ax.YMinorTick = 'on';
ax.LineWidth = 1.2;
ax.GridLineStyle = ':';
ax.FontName = 'Cambria';
ax.FontSize = 12;
ax.GridAlpha = .5;

10.移除右上部刻度

matlab 复制代码
box off
ax = axes('Position',get(gca,'Position'),...
'Color','none',...
'XAxisLocation','top',...
'YAxisLocation','right',...
'XColor','k',...
'YColor','k');
set(ax,'YTick', []);
set(ax,'XTick', []);
相关推荐
今天也想MK代码1 小时前
rust编程实战:实现3d粒子渲染wasm
开发语言·rust·wasm
结衣结衣.1 小时前
【Qt】自定义信号和槽函数
开发语言·c++·qt·c++11
尘鹄2 小时前
一文讲懂Go语言如何使用配置文件连接数据库
开发语言·数据库·后端·golang
qq_433554542 小时前
C++ 二叉搜索树代码
开发语言·c++·算法
好看资源平台2 小时前
手写识别革命:Manus AI如何攻克多语言混合识别难题(二)
开发语言·人工智能·php
Hopebearer_2 小时前
vue3中ref和reactive的区别
开发语言·前端·javascript·vue.js·前端框架·ecmascript
lly2024062 小时前
CentOS Docker 安装指南
开发语言
我命由我123452 小时前
Java Maven 项目问题:com.diogonunes:JColor:jar:5.5.1 was not found in...
java·开发语言·java-ee·maven·intellij-idea·jar·intellij idea
烂蜻蜓4 小时前
深入理解 HTML 元素:构建网页的基础
开发语言·前端·css·html·html5
Jason-河山7 小时前
如何在PHP爬虫中处理异常情况的详细指南
开发语言·爬虫·php