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

5 vues (au cours des 30 derniers jours)
Arun Prasath
Arun Prasath le 17 Oct 2023
Commenté : Voss le 20 Oct 2023
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 commentaires
Voss
Voss le 18 Oct 2023
cs and ss are undefined in the posted code.
Arun Prasath
Arun Prasath le 18 Oct 2023
Apologies. Please insert these these lines.
cs = crystalSymmetry('321');
ss = specimenSymmetry('1');

Connectez-vous pour commenter.

Réponse acceptée

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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Help Center et File Exchange

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by