【问题标题】:How do I adjust subplots from a .fig file in Matlab如何从 Matlab 中的 .fig 文件调整子图
【发布时间】:2017-11-13 13:37:21
【问题描述】:

我有一个 .fig 文件,其中包含 9 个子图,按 3 x 3 排列。现在我想将我在 plotlabels(i) 中写入的标签添加到子图 i 上的点 (xcoordinates(i),0.01)。我试试这个

plotlabels = ['A','B','C','D','E','F','G','H','I'];
xcoordinates = [30,1000,1000,1000,1000,1000,1000,1000,1000];
fig = openfig('degreedistribution.fig');

for i = drange(1,9)
     subplot(3,3,i);
     text(xcoordinates(i),0.01,plotlabels(i),'FontWeight','bold'); hold on
end

该图与子图 1、4 和 7(左列)blanc 一起返回。在其他子图中,在正确的位置添加了正确的标签。我检查了子图 1、4 和 7 中的标签位置是否与图兼容。那么发生了什么?

【问题讨论】:

    标签: matlab text subplot fig


    【解决方案1】:

    我假设它是轴。

    因为我没有你的身影,所以我试过没有那行:

    plotlabels = ['A','B','C','D','E','F','G','H','I'];
    xcoordinates = [30,1000,1000,1000,1000,1000,1000,1000,1000];
    for i = drange(1,9)
       subplot(3,3,i);
       text(xcoordinates(i),0.01,plotlabels(i),'FontWeight','bold'); hold on; 
    end
    

    您可以看到没有显示任何标签,但是,所有 x 轴都是 [0-1]。如果我在text(... 之后添加axis([0 2000 0 0.02]) 行,那么我可以看到所有标签:

    【讨论】:

    • 我试过了,但问题似乎是命令 'subplot(3,3,i)' 在 i=1,4,7 的情况下开始一个新的子图,并覆盖我的数据。即使我改变了轴,旧的情节也无处可寻..
    • @DM037 但是,我们无法复制其中的任何内容,因为您没有提供minimal reproducible example
    【解决方案2】:

    一个最小的工作示例会很有帮助。

    您可以手动将每个文本分配给其父轴:

    for i = 1:9
         t = text(xcoordinates(i),0.01,plotlabels(i),'FontWeight','bold'); 
         t.Parent = fig.Children(i);
    end
    

    【讨论】:

      猜你喜欢
      • 2021-11-09
      • 2011-02-27
      • 2015-06-15
      • 2017-09-19
      • 1970-01-01
      • 2011-12-31
      • 2012-10-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多