如何在matlab的双色标题上添加标题?(How to put a title on a biplot in matlab?)
我在matlab中创建了一个biplot
biplot = biplot(wcoeff(:,1:2),'Scores',score(:,1:2),'VarLabels',drugsFixed,'ObsLabels',cellLines,'MarkerSize',15)
它看起来很棒,但我想添加一个标题。 将'title'添加到biplot函数调用会导致错误。 'biplot'对象没有任何看起来可能有标题句柄的子对象。 建议?
I have created a biplot in matlab
biplot = biplot(wcoeff(:,1:2),'Scores',score(:,1:2),'VarLabels',drugsFixed,'ObsLabels',cellLines,'MarkerSize',15)
It looks great, but I'd like to add a title. Adding 'title' to the biplot function call results in an error. The 'biplot' object doesn't have any children that look like they might have the title handle in it. Suggestions?
原文:https://stackoverflow.com/questions/45221301
更新时间:2020-02-19 06:10
最满意答案
与许多绘图功能一样,我可以通过调用title来跟进我对biplot的调用,为当前数字添加标题。
%% Biplot of Coefficients and Scores
% https://www.mathworks.com/help/stats/biplot.html#bt_y8xe-2
% Load the sample data.
% Copyright 2015 The MathWorks, Inc.
load carsmall
%%
% Define the variable matrix and delete the rows with missing values.
x = [Acceleration Displacement Horsepower MPG Weight];
x = x(all(~isnan(x),2),:);
%%
% Perform a principal component analysis of the data.
[coefs,score] = pca(zscore(x));
%%
% View the data and the original variables in the space of the first three
% principal components.
vbls = {'Accel','Disp','HP','MPG','Wgt'};
biplot(coefs(:,1:3),'scores',score(:,1:3),'varlabels',vbls);
%Add the title
title('My title');
如果正确的数字不是最新的,您可以通过调用figure(f)来更改当前数字,其中f是您要添加标题的数字句柄。
As with many plotting functions, I can follow up my call to biplot with a call to title to add a title to the current figure.
%% Biplot of Coefficients and Scores
% https://www.mathworks.com/help/stats/biplot.html#bt_y8xe-2
% Load the sample data.
% Copyright 2015 The MathWorks, Inc.
load carsmall
%%
% Define the variable matrix and delete the rows with missing values.
x = [Acceleration Displacement Horsepower MPG Weight];
x = x(all(~isnan(x),2),:);
%%
% Perform a principal component analysis of the data.
[coefs,score] = pca(zscore(x));
%%
% View the data and the original variables in the space of the first three
% principal components.
vbls = {'Accel','Disp','HP','MPG','Wgt'};
biplot(coefs(:,1:3),'scores',score(:,1:3),'varlabels',vbls);
%Add the title
title('My title');
If the correct figure is not current, you can change the current figure by calling figure(f) where f is the figure handle that you want to add the title to.
2017-07-20
相关问答
这一定必须奏效: X=rand(10,1)
Y=rand(10,1)
plot(X,Y)
title('na\"{i}ve','interpreter','latex');
如果需要,还可以更改字体和大小等。 顺便说一句,看看 http://en.wikibooks.org/wiki/LaTeX/Special_Characters This must work: X=rand(10,1)
Y=rand(10,1)
plot(X,Y)
title('na\"{i}ve','interpreter
...
您需要在弹出菜单旁边添加另一个 ui对象 ,可能是text或edit : (我个人更喜欢edit因为它看起来更好) txt_obj = uicontrol(...
'Style','edit',...
'HorizontalAlignment','right',...
'String', 'Something',...
'Position' , [0,400,100,24],...
'BackgroundColor', [.9 .9 .9],...
...
双biplot中的主成分分数(红点)不是pca函数返回的分数。 作为帮助状态, biplot对分数进行缩放以使它们适合于绘图:它将每个分数除以所有分数的最大绝对值,并乘以coefs的最大系数长度。 然后,biplot根据coefs的符号约定改变得分坐标的符号。 因此,您无法轻易使用(X,Y)信息来找出属于某个类别的点。 这是使用ObsLabels选项的解决方法。 ObsLabels为每个观察分配一些用户定义的数据:对于每个点,我们将分配对应于status变量的索引(简单的递增值)。 通过这种方式,
...
试着给 rownames(data)
在使用princomp之前 Try giving rownames(data)
before using princomp
我认为你应该尝试theme(legend.position="none") 。 library(factoextra)
plot(fviz_pca_biplot(pca, label="var",
habillage=as.factor(kc$cluster)) + ggtitle("") +
theme(text = element_text(size = 15),
panel.background = element_blank(),
panel.gr
...
诀窍是使用\''{a}并确保解释器设置为latex(而不是tex)。 例: title('Maxim\''{a}ln\''{i}','FontSize',30,'Interpreter','latex')
The trick is to use \''{a} and to be sure that the interpreter is set to latex (not tex). Example: title('Maxim\''{a}ln\''{i}','FontSize',30,'Inter
...
与许多绘图功能一样,我可以通过调用title来跟进我对biplot的调用,为当前数字添加标题。 %% Biplot of Coefficients and Scores
% https://www.mathworks.com/help/stats/biplot.html#bt_y8xe-2
% Load the sample data.
% Copyright 2015 The MathWorks, Inc.
load carsmall
%%
% Define the variable mat
...
对于Matlab 7: jDesktop = com.mathworks.mde.desk.MLDesktop.getInstance;
jDesktop.getMainFrame.setTitle('my new title');
*或专门用于命令窗口: cmdWin = jDesktop.getClient('Command Window');
cmdWin.getTopLevelAncestor.setTitle('my new title');
对于Matlab 6: jDesktop
...