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

2 views (last 30 days)
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 Comments
Arun Prasath
Arun Prasath on 18 Oct 2023
Apologies. Please insert these these lines.
cs = crystalSymmetry('321');
ss = specimenSymmetry('1');

Sign in to comment.

Accepted Answer

Voss
Voss on 18 Oct 2023
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 Comments
dpb
dpb on 20 Oct 2023
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 on 20 Oct 2023
It's from a third-party toolbox, which apparently doesn't follow the sensible plot() output convention that TMW has established.

Sign in to comment.

More Answers (0)

Categories

Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!