在 Matlab Bioinformatics Toolbox 的 HeatMap() 中更改字体
Change font in HeatMap() of Matlab Bioinformatics Toolbox
我在 Matlab 2016a 中使用生物信息学工具箱。我使用 mat = DataMatrix()
创建了一个带有行和列标签的矩阵,然后我使用 fig = HeatMap(mat)
创建了一个热图。行和列标签会自动添加到生成的图形中。
我想将生成的图形中的所有字体更改为 Arial。我还想停止将下划线解释为下标。但是,命令:
fig = HeatMap(mat,'Colormap','fontName','Arial','Interpreter','none')
导致错误:
Unknown parameter name: fontName.
Unknown parameter name: Interpreter.
和命令:
set(fig,'fontName','Arial','Interpreter','none')
结果:
The name 'fontName' is not an accessible property for an instance of class 'HeatMap'.
The name 'Interpreter' is not an accessible property for an instance of class 'HeatMap'.
怎样才能得到我想要的结果?
在这里,HeatMap 视图(构造 HeatMap 对象时显示的内容)不等同于常规绘图,并且相当不灵活。幸运的是,HeatMap 可以呈现为绘图,这样就可以进行操作。该示例摘自 This Mathworks site.
load filteredyeastdata
yeastvalues = yeastvalues(1:5, 1:4);
genes = genes(1:5, :);
genes = strrep(genes, 'L', 'L_'); %// simulate underscores
times = times(1:4);
dat = DataMatrix(yeastvalues, genes, times);
heatmap = HeatMap(dat); %// no way to suppress?
可以使用 properties(<object>)
或 set(<object>)
(列出当前设置)查看 HeatMap
对象的可用属性。从那里可以直接看出哪些属性不可用(没有 'fontName' 或 'Interpreter')。
Mathworks 为我们提供了一种 plot
热图方法,这为我们提供了更广泛的选择。
plt = plot(heatmap); %// render the heat map and give us a handle
有很多与 plt
相关的属性,但看起来您想要的是 'TickLabelInterpreter'(参见 Axes Properties)。
set
可以将元胞数组或键值对作为输入,这样我们就可以一次设置多个属性。
set(plt, {'Fontname', 'TickLabelInterpreter'}, {'Comic Sans MS', 'none'});
%// or set(plt, 'Fontname', 'Comic Sans MS', 'TickLabelInterpreter', 'none');
请注意,MATLAB 区分大小写!
我在 Matlab 2016a 中使用生物信息学工具箱。我使用 mat = DataMatrix()
创建了一个带有行和列标签的矩阵,然后我使用 fig = HeatMap(mat)
创建了一个热图。行和列标签会自动添加到生成的图形中。
我想将生成的图形中的所有字体更改为 Arial。我还想停止将下划线解释为下标。但是,命令:
fig = HeatMap(mat,'Colormap','fontName','Arial','Interpreter','none')
导致错误:
Unknown parameter name: fontName.
Unknown parameter name: Interpreter.
和命令:
set(fig,'fontName','Arial','Interpreter','none')
结果:
The name 'fontName' is not an accessible property for an instance of class 'HeatMap'.
The name 'Interpreter' is not an accessible property for an instance of class 'HeatMap'.
怎样才能得到我想要的结果?
在这里,HeatMap 视图(构造 HeatMap 对象时显示的内容)不等同于常规绘图,并且相当不灵活。幸运的是,HeatMap 可以呈现为绘图,这样就可以进行操作。该示例摘自 This Mathworks site.
load filteredyeastdata
yeastvalues = yeastvalues(1:5, 1:4);
genes = genes(1:5, :);
genes = strrep(genes, 'L', 'L_'); %// simulate underscores
times = times(1:4);
dat = DataMatrix(yeastvalues, genes, times);
heatmap = HeatMap(dat); %// no way to suppress?
可以使用 properties(<object>)
或 set(<object>)
(列出当前设置)查看 HeatMap
对象的可用属性。从那里可以直接看出哪些属性不可用(没有 'fontName' 或 'Interpreter')。
Mathworks 为我们提供了一种 plot
热图方法,这为我们提供了更广泛的选择。
plt = plot(heatmap); %// render the heat map and give us a handle
有很多与 plt
相关的属性,但看起来您想要的是 'TickLabelInterpreter'(参见 Axes Properties)。
set
可以将元胞数组或键值对作为输入,这样我们就可以一次设置多个属性。
set(plt, {'Fontname', 'TickLabelInterpreter'}, {'Comic Sans MS', 'none'});
%// or set(plt, 'Fontname', 'Comic Sans MS', 'TickLabelInterpreter', 'none');
请注意,MATLAB 区分大小写!