我在matlab中创建了一个双图。
biplot = biplot(wcoeff(:,1:2),'Scores',score(:,1:2),'VarLabels',drugsFixed,'ObsLabels',cellLines,'MarkerSize',15)它看上去很棒,但我想加一个标题。将'title'添加到双绘图函数调用将导致错误。“might”对象中没有任何看起来可能有标题句柄的子对象。有什么建议吗?
发布于 2017-07-20 17:32:46
与许多绘图函数一样,我可以在调用biplot之后调用title,将标题添加到当前图形中。
%% 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是要添加标题的图形句柄。
发布于 2017-07-20 17:36:10
发布于 2017-07-20 17:38:51
我认为>>title以及>>xlabel和>>ylabel必须在实际情节之外被调用。我假设以下代码将在您的m文件中的某个位置:
biplot(*All of the parameters go in here*)
title('This is a title.')
xlabel('This labels the x-axis.')
ylabel('This labels the y-axis.')这里是MATLAB的标题文档,如果你需要的话。我发现MathWorks对它们的文档非常透彻。
https://stackoverflow.com/questions/45221301
复制相似问题