dat*_*tcn 23 matlab plot annotations figure
我知道有一个名为annotation的函数可以绘制箭头或双箭头.但是注释只能以标准化单位绘制.例如:
annotation('arrows',[x1 x2],[y1 y2])
Run Code Online (Sandbox Code Playgroud)
这里,[x1,x2]应该是小于1的比率数.
所以,我的问题是如何绘制具有真值而不是标准化值的箭头?
我想知道是否有任何其他功能可以接近这个或者是否有任何函数我可以得到图的轴值,以便我可以将真值调整为标准化值.
H.M*_*ter 12
对于注释的定位,Matlab提供了dsxy2figxy将数据空间点转换为标准化空间坐标的功能.但是,无论出于何种原因,该功能都不包含在Matlab发行版中,必须先"创建".
将以下行复制到命令窗口并执行它以在编辑器中打开该功能.
edit(fullfile(docroot,'techdoc','creating_plots','examples','dsxy2figxy.m'))
Run Code Online (Sandbox Code Playgroud)
要使用该功能,dsxy2figxy请将其保存在matlab搜索路径中的某个位置.
请dsxy2figxy在matlab-central上找到该功能的完整说明:http://www.mathworks.de/help/techdoc/creating_plots/bquk5ia-1.html
mar*_*sei 10
即使annotation使用normalized作为默认的单位,可以将这些对象到当前的轴(副gca),并使用数据单位设置X和Y属性.
以下是绘制单箭头的示例.
plot(1:10);
ha = annotation('arrow'); % store the arrow information in ha
ha.Parent = gca; % associate the arrow the the current axes
ha.X = [5.5 5.5]; % the location in data units
ha.Y = [2 8];
ha.LineWidth = 3; % make the arrow bolder for the picture
ha.HeadWidth = 30;
ha.HeadLength = 30;
Run Code Online (Sandbox Code Playgroud)
我刚刚发现了这种方法,因为我不想打扰标准化单位.使用乳胶解释器:
figure
plot([1:5],[1:5]*3,'.-')
%// Say I want to put an arrow pointing to the location, [3 9]
text(2.94,8.3,'\uparrow','fontsize',20)
text(2.8,7.8,'point [3,9]')
Run Code Online (Sandbox Code Playgroud)
要使箭头更长,请使用更大的字体大小.
优点
缺点