【问题标题】:Align inset in matlab plot to the right将matlab图中的插图向右对齐
【发布时间】: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


【解决方案1】:

这是一种方法:

基本上创建一个带有轴的图形,然后添加一个新轴,将其放置到特定位置并为其指定所需大小。

代码:

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)

然后输出:

为了幻想,您可以使用新的坐标轴位置,以便外边框与大边框重合,但这应该可以帮助您:)

【讨论】:

  • 谢谢你的好例子,但在谈到对齐时,我想到的是重合对齐,而不仅仅是平行......
  • 好的。在您的原始问题中,情况并非如此/指定。我会编辑我的答案
猜你喜欢
  • 2018-03-31
  • 1970-01-01
  • 2023-04-01
  • 1970-01-01
  • 2017-12-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多