使用彩色文本在图外添加描述
Adding description outside the plot with coloured text
我正在对我的数据进行可视化处理,想添加对绘图的描述。描述将添加到情节之外。为此,我写了:
plot(1:10)
text(2,8,'my text here ','Color','green','FontSize',14,'location','EastOutside')
但是它不起作用,我收到错误消息:
There is no location property on the Text class.
我该如何解决这个问题?
这是我想要的输出:
您提供给 text
的 location
输入对用于 legend
,而不是 text
对象...
位置由前两个输入 (x/y) 指定,因此如果您不使用 location
输入,您将得到:
text( 2, 8, 'my text here ', 'Color', 'green', 'FontSize', 14 )
如果您希望文本位置独立于坐标轴,您应该使用 annotation
,它从 图 而不是 轴.
annotation( 'textbox', 'String', 'my annotation', 'Color', 'green', ...
'FontSize', 14, 'Units', 'normalized', 'EdgeColor', 'none', ...
'Position', [0.8,0.5,0.2,0] )
因为我这里用的是normalized
位置,所以Position
参数是数字window的百分比。要获得我怀疑您想要的行为,您也必须重新定位轴...
set( gca, 'Position', [0.1, 0.1, 0.6, 0.8] )
text()
如果您想在图中的某处进行任意描述,则可以使用
text()
,但如果您只想将图例放在外面,请使用 [=11= 中的名称-值对位置].该示例将图例放在图的右上角。
我正在对我的数据进行可视化处理,想添加对绘图的描述。描述将添加到情节之外。为此,我写了:
plot(1:10)
text(2,8,'my text here ','Color','green','FontSize',14,'location','EastOutside')
但是它不起作用,我收到错误消息:
There is no location property on the Text class.
我该如何解决这个问题?
这是我想要的输出:
您提供给 text
的 location
输入对用于 legend
,而不是 text
对象...
位置由前两个输入 (x/y) 指定,因此如果您不使用 location
输入,您将得到:
text( 2, 8, 'my text here ', 'Color', 'green', 'FontSize', 14 )
如果您希望文本位置独立于坐标轴,您应该使用 annotation
,它从 图 而不是 轴.
annotation( 'textbox', 'String', 'my annotation', 'Color', 'green', ...
'FontSize', 14, 'Units', 'normalized', 'EdgeColor', 'none', ...
'Position', [0.8,0.5,0.2,0] )
因为我这里用的是normalized
位置,所以Position
参数是数字window的百分比。要获得我怀疑您想要的行为,您也必须重新定位轴...
set( gca, 'Position', [0.1, 0.1, 0.6, 0.8] )
text()
如果您想在图中的某处进行任意描述,则可以使用
text()
,但如果您只想将图例放在外面,请使用 [=11= 中的名称-值对位置].该示例将图例放在图的右上角。