【问题标题】:add tabs (spaces) to strings in plots for Octave / Matlab在 Octave / Matlab 的图中为字符串添加制表符(空格)
【发布时间】:2023-03-25 18:42:01
【问题描述】:

如何在 Octave 中为绘图添加制表符(空格),请参见下面的代码。它不会创建 选项卡(图中 Signal 和 Max Freq 之间应该有一个选项卡)

它还会产生警告消息

警告:text_renderer:跳过字符“9”的缺失字形 警告:调用自 注释>update_textbox 在第 1080 行第 11 列 第 248 行第 7 列的注释

clf
plot(0:0)
var=456
t1='Signal ';
t2=[char(9), 'Max Freq'];
t3=[char(10), 'nextline',num2str(var)];
str=strcat(t1,t2,t3);
annotation('textbox',...
[0.15 0.65 0.3 0.15],...
'String',{str},...
'FontSize',14,...
'FontName','Arial',...
'LineStyle','--',...
'EdgeColor',[1 1 0],...
'LineWidth',2,...
'BackgroundColor',[0.9  0.9 0.9],...
'Color',[0.84 0.16 0]);

Ps:我在 Ubuntu 18.04 64bit 上使用 Octave 4.2.2

【问题讨论】:

  • tabstr = sprintf('\t') 工作吗?
  • @jodag 不幸的是,这不起作用。
  • 为什么不为每个制表位创建一个单独的文本框?在我看来,排列文本的最简单方法。
  • 从我刚刚运行的一些实验来看,MATLAB 文本框中的选项卡似乎被忽略了。

标签: matlab gnuplot octave


【解决方案1】:

我为空白添加了 t4...看起来不太好。另请注意,我使用的是 Matlab,而不是 Octave,所以我没有收到您的错误。不确定。

clf
plot(0:0)
var=456
t1='Signal ';
t4 = blanks(5);
t2=[char(9),t4, 'Max Freq'];
t3=[char(10), 'nextline',num2str(var)];
str=strcat(t1,t2,t3);
annotation('textbox',...
[0.15 0.65 0.3 0.15],...
'String',{str},...
'FontSize',14,...
'FontName','Arial',...
'LineStyle','--',...
'EdgeColor',[1 1 0],...
'LineWidth',2,...
'BackgroundColor',[0.9  0.9 0.9],...
'Color',[0.84 0.16 0]);

【讨论】:

    猜你喜欢
    • 2021-06-08
    • 2020-09-16
    • 1970-01-01
    • 2012-04-16
    • 2014-04-17
    • 1970-01-01
    • 1970-01-01
    • 2013-02-04
    • 1970-01-01
    相关资源
    最近更新 更多