管理 Matlab 绘图上文本的字体类型和大小
Manage font type and size of text on Matlab plot
我已经实现了在 Matlab 上绘制 28x28 灰度图像并在图形的特定位置插入数字,但是如何增加字体的大小、更改其颜色或类型(例如 verdana ).
% myImage is a 28x28 matrix with values from 0 to 255
imagesc(myImage);
colormap(gray)
%insert text
text(1,1,'7');
是的。使用 'FontName'
属性。如果要更改大小,请使用 'FontSize'
,最后更改颜色,请使用 'Color'
属性...像这样:
text(1, 1, '7', 'FontName', 'verdana', 'FontSize', 16, 'Color', 'blue');
将上述属性更改为任何你想要的,但我将字体大小设置为 16,字体 Verdana 和文本颜色为蓝色。有关 text
函数及其属性的更多信息,请参阅 MathWorks 官方文档:http://www.mathworks.com/help/matlab/ref/text-properties.html
这是一个实际的例子:
>> im = rand(7,7);
>> imagesc(im);
>> text(1, 1, '7', 'FontName', 'verdana', 'FontSize', 16, 'Color', 'red');
我们得到这个数字:
您可以看到我们切换到了 Verdana,并且我们在图像中放置了一个字体大小为 16 且位置为 (1,1)
的蓝色 7。
我已经实现了在 Matlab 上绘制 28x28 灰度图像并在图形的特定位置插入数字,但是如何增加字体的大小、更改其颜色或类型(例如 verdana ).
% myImage is a 28x28 matrix with values from 0 to 255
imagesc(myImage);
colormap(gray)
%insert text
text(1,1,'7');
是的。使用 'FontName'
属性。如果要更改大小,请使用 'FontSize'
,最后更改颜色,请使用 'Color'
属性...像这样:
text(1, 1, '7', 'FontName', 'verdana', 'FontSize', 16, 'Color', 'blue');
将上述属性更改为任何你想要的,但我将字体大小设置为 16,字体 Verdana 和文本颜色为蓝色。有关 text
函数及其属性的更多信息,请参阅 MathWorks 官方文档:http://www.mathworks.com/help/matlab/ref/text-properties.html
这是一个实际的例子:
>> im = rand(7,7);
>> imagesc(im);
>> text(1, 1, '7', 'FontName', 'verdana', 'FontSize', 16, 'Color', 'red');
我们得到这个数字:
您可以看到我们切换到了 Verdana,并且我们在图像中放置了一个字体大小为 16 且位置为 (1,1)
的蓝色 7。