【发布时间】:2015-02-23 21:33:04
【问题描述】:
如何将 MATLAB 绘图的插图与框的右上角对齐,如图所示?
该示例是使用 GNU R 生成的,如 How to add an inset (subplot) to "topright" of an R plot? 中所述
【问题讨论】:
-
那么你有没有尝试我的建议?
标签: matlab plot alignment insets
如何将 MATLAB 绘图的插图与框的右上角对齐,如图所示?
该示例是使用 GNU R 生成的,如 How to add an inset (subplot) to "topright" of an R plot? 中所述
【问题讨论】:
标签: matlab plot alignment insets
这是一种方法:
基本上创建一个带有轴的图形,然后添加一个新轴,将其放置到特定位置并为其指定所需大小。
代码:
clc
clear
close all
%// Dummy data
x = -20:0;
x2 = x(5:10);
%// Zoomed region to put into inset.
y = x.^2;
y2 = y(5:10);
%// Create a figure
hFig = figure(1);
%// Plot the original data
hP1 = plot(x,y);
xlabel('Original x','FontSize',18)
ylabel('Original y','FontSize',18)
hold on
%// Add an axes and set its position to where you want. Its in normalized
%// units
hAxes2 = axes('Parent',hFig,'Position',[.58 .6 .3 .3]);
%// Plot the zommed region
plot(x2,y2,'Parent',hAxes2)
%// Set the axis limits and labels
set(gca,'Xlim',[x(5) x(10)])
xlabel('Zoomed x','FontSize',16)
ylabel('Zommed y','FontSize',16)
然后输出:
为了幻想,您可以使用新的坐标轴位置,以便外边框与大边框重合,但这应该可以帮助您:)
【讨论】: