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

2 visualizzazioni (ultimi 30 giorni)
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 Commenti
Arun Prasath
Arun Prasath il 18 Ott 2023
Apologies. Please insert these these lines.
cs = crystalSymmetry('321');
ss = specimenSymmetry('1');

Accedi per commentare.

Risposta accettata

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

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Creating, Deleting, and Querying Graphics Objects in Help Center e File Exchange

Prodotti


Release

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by