Matlab:打开属性编辑器或绘图浏览器强制正确的文本框注释;如果没有它,注释就会失败

发布于 2024-11-15 16:36:19 字数 918 浏览 2 评论 0原文

我有一个运行良好的程序,它获取文件,绘制它们,输出一个pdf(字母大小)。我使用注释将标题放在一组三个子图上方,并用作包含文件信息和日期的页脚。我希望标题位于页面顶部,从边距到边距填充,居中。

我有两种运行程序的方式:“批处理”模式和“交互”模式。在“交互”模式下,我使用简单的 figure() 命令创建图形。在“批处理”模式下,我使用 figure('visible','off') 创建图形。这是我用于进行注释的命令:

annotation(obj.hFigure(f),'textbox',[0 0.9 1 0.1],...
    'String',title,...
    'HorizontalAlignment','center',...
    'FontSize',18,...
    'LineStyle','none',...
    'FitBoxToText','off');

这里,“obj.hFigure(f)”只是我当前正在处理的图形的句柄。正如您所看到的,我将图形放置在图形顶部附近,并确保文本从框底部延伸(如果它更大)。

我的问题是上述注释上的边距。在批处理模式下(没有显示数字),我在文本两侧都有 10% 左右的边距,这会破坏布局。在交互模式下(显示数字),我没有得到边距:文本正确地从一个边缘流到另一边缘。

我已将问题范围缩小到以下范围:如果我使数字可见 (figure('visible','on'))

propertyeditor(gcf);
plotbrowser(gcf);

>AND在绘制每个图形后 。这使得程序花费大约两倍的时间(这并不是什么大问题)。但我不明白的是:这两个命令有什么作用,而 drawnowrefresh 无法完成?!

I have a generally happily running program that takes files, plots them, spits out a pdf (letter size). I use annotations to put in a title above a set of three subplots, and to use as a footer with file info and date. I would like the title to be at the top of the page, filling up from margin to margin, centered.

I have two ways of running the program: in 'batch' mode and 'interactive' mode. When in 'interactive' mode, I create the figure with a simple figure() command. When in 'batch' mode, I create the figure with figure('visible','off'). Here is my command for making the annotation:

annotation(obj.hFigure(f),'textbox',[0 0.9 1 0.1],...
    'String',title,...
    'HorizontalAlignment','center',...
    'FontSize',18,...
    'LineStyle','none',...
    'FitBoxToText','off');

Here, "obj.hFigure(f)" is simply a handle to the figure I am currently processing. As you can see, I place the figure near the top of the figure, and make sure that the text runs off the bottom of the box (in case it is larger).

My problem is with margins on the above annotation. In batch mode (no figures showing), I get 10% or so margins on either side of the text, which ruins the layout. In interactive mode (figures show up), I don't get the margins: the text correctly flows from one edge to the other.

I have narrowed down the problem to the following: I can get the correct response to the ps printing in batch mode if I make the figures visible (figure('visible','on')) AND open up

propertyeditor(gcf);
plotbrowser(gcf);

after each figure is plotted. This makes the program take about twice as long (which isn't a huge deal). But what I don't understand is: what do those two commands do that drawnow or refresh don't accomplish?!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

野却迷人 2024-11-22 16:36:19

我不确定您的具体情况,但是过去遇到此类问题时,我通过使用以下命令显式设置图形大小取得了巨大成功:

set(gcf, 'Position', [100  100  300 300])

然后,在打印/保存之前将 PaperPositionMode 设置为 auto,这似乎强制打印图形的大小与屏幕上显示的大小相同:

set(gcf, 'PaperPositionMode','auto')

I am unsure about your specific case, but when encountering this kind of problem in the past I have had great success by explicitly setting the figure size with:

set(gcf, 'Position', [100  100  300 300])

and then, before printing/saving setting the PaperPositionMode to auto, which seems to force the printed figure to be the same size as the one shown on screen:

set(gcf, 'PaperPositionMode','auto')
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文