【问题标题】:Changing font size on one line in multiline plot label in Octave在 Octave 的多线绘图标签中更改一行的字体大小
【发布时间】:2021-07-25 05:33:33
【问题描述】:

是否可以使用 ylabel 命令更改多行绘图标签中一行文本的字体大小。如果有怎么办?

PS:我使用的是 Octave 5.2

我尝试了下面的代码,但它给了我一个错误。

figure
plot((1:10).^2)
ylabel_txt1=strcat('1st line of text with smaller font') %1st line
ylabel_txt2=strcat('2nd line of text') %2nd line
ylabel({(ylabel_txt1,'fontsize',13) ;ylabel_txt2})

【问题讨论】:

  • 另一种选择是创建一个“虚拟”轴对象,放置在下方,用于创建所需的标签
  • @TasosPapastylianou 听起来很有趣我只是不知道你指的是什么..create a 'dummy' axes object, placed below

标签: plot octave axis-labels


【解决方案1】:

ylabel 默认使用tex 解释器,tex 解释器允许使用\fontsize{size} 更改文本中任意位置的字体大小。

这是你应该做的:

ylabel({['\fontsize{13}', ylabel_txt1]; ['\fontsize{10}', ylabel_txt2]})

对于其他格式选项,您可以查看文档中的“文本属性”页面。

【讨论】:

    【解决方案2】:

    由于有人要求澄清,因此将我的评论扩展到答案。
    希望代码是不言自明的:)

    ylabel_txt1 = '1st line of text with smaller font'; % 1st line
    ylabel_txt2 = '2nd line of text';                   % 2nd line
    
    F   = figure()
    Ax1 = axes()
    Ax2 = axes()
    
    % create Ax2, make everything invisible except for ylabel
    axes( Ax2 )
    set( Ax2, 'color', 'none', 'xcolor', 'none', 'ycolor', 'none' )
    ylabel( {ylabel_txt2, ' ', ' ', ' '}, 'fontsize', 16, 'color', 'k' );
    
    % now 'create' Ax1 on top of Ax2
    axes( Ax1 )
    plot( (1:10) .^ 2 )
    ylabel( ylabel_txt1, 'fontsize', 13 );
    

    【讨论】:

    • 谢谢!我现在明白了:-)
    猜你喜欢
    • 1970-01-01
    • 2014-12-19
    • 1970-01-01
    • 2019-08-06
    • 1970-01-01
    • 1970-01-01
    • 2015-10-27
    • 1970-01-01
    • 2021-07-19
    相关资源
    最近更新 更多