Multiple plots in a single figure not working correctly for pole plots

2 次查看(过去 30 天)
Hi,
I was reading a set of crystal euler angles in the format
phi1_1 phi_1 phi2_1
phi1_2 phi_2 phi2_2
...
...
...
phi1_n phi_n phi2_n
from an external file and use the following code to plot the pole figures
filename = 'pcrystal_standard.csv';
fileID = fopen(filename);
C = textscan(fileID,'%f %f %f');
fclose(fileID);
ncrys = cellfun(@length, C(1,1));
for i =1:ncrys
phi1=deg2rad(C{1,1}(i,1));
phi=deg2rad(C{1,2}(i,1));
phi2=deg2rad(C{1,3}(i,1));
ori = orientation.byEuler(phi1,phi,phi2,cs,ss);
h = Miller({1,0,0},cs);
r1 = ori * h.symmetrise;
plot(r1);
hold on;
end
hold off;
After plotting each of the crystal orientations, i hold the plot with "hold on;" to make sure the points are plotted in the same figure. One of the plot corresponding to the upper symmetry elements, fail to recognize the hold and does not add the points, while the lower one does it correctly. Attached figure might explain this better. Not sure why this happens, but probably some one has answers.
  7 个评论
Arun Prasath
Arun Prasath 2023-10-18
Apologies. Please insert these these lines.
cs = crystalSymmetry('321');
ss = specimenSymmetry('1');

请先登录,再进行评论。

采纳的回答

Voss
Voss 2023-10-18
Try this:
cs = crystalSymmetry('321');
ss = specimenSymmetry('1');
filename = 'pcrystal_standard.csv';
fileID = fopen(filename);
C = textscan(fileID,'%f %f %f');
fclose(fileID);
ncrys = cellfun(@length, C(1,1));
for i = 1:ncrys
phi1=deg2rad(C{1,1}(i,1));
phi=deg2rad(C{1,2}(i,1));
phi2=deg2rad(C{1,3}(i,1));
ori = orientation.byEuler(phi1,phi,phi2,cs,ss);
h = Miller({1,0,0},cs);
r1 = ori * h.symmetrise;
if i == 1
[~,ax] = plot(r1);
hold(ax,'on');
else
plot(r1,'parent',ax);
end
end
hold(ax,'off');
The idea is: the first time you plot, you store the two axes created (ax) by that plot call, then every subsequent time, you tell plot to plot into those same axes again. Also, you need to tell hold which axes to hold on and off.
  8 个评论
dpb
dpb 2023-10-20
Not used to a plot() derivative creating multiple axes...that's unusual. Most return line or other graphics objects handles or a standalone chart object is a new aberration, but alternate returns and more than one axis -- that is, afaik, the only one???
Voss
Voss 2023-10-20
It's from a third-party toolbox, which apparently doesn't follow the sensible plot() output convention that TMW has established.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Creating, Deleting, and Querying Graphics Objects 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by