필터 지우기
필터 지우기

How can I add a title using slice plots?

조회 수: 2 (최근 30일)
Liz Lala
Liz Lala 2019년 4월 25일
편집: Adam Danz 2019년 4월 26일
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
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
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
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개)

카테고리

Help CenterFile Exchange에서 Title에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by