How can I add a title using slice plots?
3 次查看(过去 30 天)
显示 更早的评论
Hey folks,
this is my first question in a forum ever XD (confetti)
I have a volume of measured data and found "slice" beeing perfect to plot those, but I dont know how to add a title and axes labels afterwards.
[Y,X,Z] = meshgrid(Ycm, Xcm, Zcm);
xslice = [Xcm(1),Xcm(2),Xcm(3),Xcm(4),Xcm(5),Xcm(6),Xcm(7)]; yslice = []; zslice = []; %no slices in y or z planes
sliceplot = slice(Y,X,Z, umat, yslice,xslice,zslice);
title='test'; -> gives me nothing
sliceplot.Title='test'; -> gives me "Expected one output from a curly brace or dot indexing expression, but there were 7 results."
sliceplot(1,1).Title='test'; -> gives me "Unrecognized property 'Title' for class 'matlab.graphics.primitive.Surface'."
(I know that I can add a title manually, but there is a lot of data to be plot, so an automatic command seems useful to me)
How can I access the plot features?
~~~~~~~~~~~~~~~
found it, title('test'); works, but still, is there a way to access the plot afterwards?
3 个评论
Adam
2019-4-25
The title is a property of the axes, not the slice graphics object so you wouldn't expect:
sliceplot.Title='test';
or
sliceplot(1,1).Title='test';
to work. And
title='test';
just assigns the chars 'test' to a variable named title.
Code has to follow rules, we can't just type things that look intuitive and assume it will magically work as code!
doc title
will give information on adding titles.
Adam
2019-4-26
Properties of the slice graphics object itself are available on
slicePlot
If you want axes properties then you can get these from the axes handle, which is usually best to acquire right at the start of the process. I don't like using gca, but in the following case I find it acceptable if I am just writing a script:
figure; hAxes = gca;
Then I can use hAxes as my fixed graphics handle from there onwards.
采纳的回答
Adam Danz
2019-4-26
编辑:Adam Danz
2019-4-26
Here's a functional demo of Adam's and Kalyan's suggestions. I added a different method of getting the axis handle.
% Create slice plot
[X,Y,Z] = meshgrid(-2:.2:2);
V = X.*exp(-X.^2-Y.^2-Z.^2);
xslice = [-1.2,0.8,2];
yslice = [];
zslice = 0;
h = slice(X,Y,Z,V,xslice,yslice,zslice); %grab output handle(s)
% Get axis handle
axh = h(1).Parent; %alternative: axh = gca;
title(axh, 'title')
xlabel(axh, 'x')
ylabel(axh, 'y')
zlabel(axh, 'z')
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Title 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!