Borrar filtros
Borrar filtros

Merged plots from saved figure

3 visualizaciones (últimos 30 días)
Filip
Filip el 3 de Abr. de 2023
Respondida: Abhishek el 11 de Abr. de 2023
I want to load a plot that shows the principle shear flow and later, in same figure, also plot corrosion pits with same legends as in independet plots.
fig = openfig('export_fig_m_files\F1slab_v1.fig');
hold on
% Remove the colormap and set the line colors to the original values
% set the filename
filename = 'Coords_Corr.txt';
% load the data
data1 = importdata(filename);
data = importdata('Coords_Corr_af.txt');
add_data = importdata('additional_inf.txt',',',1);
% Separation of points between 3.rd and 4.th position to create plots
Data_d_pos_4 = data(:, 1) == 4;
Data_4 = data(Data_d_pos_4,:);
Data_d_pos_3 = data(:, 1) == 3;
Data_3 = data(Data_d_pos_3,:);
max_size_plt = 100;
min_size_plt = 20;
pointsize_4 = Data_4(:,12);
pointsize_4_max = max(pointsize_4);
pointsize_4_min = min(pointsize_4);
factor_size_4 = (max_size_plt-min_size_plt)/(pointsize_4_max-pointsize_4_min);
pointcolor_4 = Data_4(:,13);
scatter(Data_4(:, 3), Data_4(:, 4), factor_size_4.*(pointsize_4-pointsize_4_min.*ones("like",pointsize_4))+min_size_plt.*ones("like",pointsize_4), pointcolor_4,'filled', "MarkerEdgeColor", "k")
hcb = colorbar;
hcb.Title.String = "\zeta";
hold on
I have attatched plots of how the two plots look seperatly and one from what the code above outputs. I have tried to extract data from openfig(...) but it retrives me no data.
The Fslab_v1 is created using the following linesof code:
% streamslice with density
[Vert,~] = streamslice(X,Y,-VX,-VY,dens);
hold on;
max_v = 0.5*max(max(VTOT));
%max_v = 500;%default value, if needed
tam = size(Vert);
tam = tam(1,2);
for k=1:1:tam
Linha = Vert{k};
if ~isempty(Linha)
tam2 = size(Linha);
for i=1:1:tam2-1
x_ii = Linha(i+1,1);
y_ii = Linha(i+1,2);
x_i = Linha(i,1);
y_i = Linha(i,2);
x_m = x_ii*0.5+x_i*0.5;
y_m = y_ii*0.5+y_i*0.5;
v_m = interp2(X,Y,VTOT,x_m,y_m);
%espe=max_ep*(v_m/max_v)^0.5;
espe = max_ep*(v_m/max_v);
if (espe==0)
espe = 0.0000000000001;
end
if (isnan(espe))
espe = 0.00000000001;
end
h = plot(Linha(i:i+1,1),Linha(i:i+1,2),'LineWidth',espe,'Color',color_flow);
hold on;
end
end
end
hold on;

Respuestas (1)

Abhishek
Abhishek el 11 de Abr. de 2023
Hi Filip,
Based on my understanding, it seems that you are facing challenge in retrieving data from the generated fig file. To assist you with this issue, I would like to suggest the following code snippet for your reference:
fig = openfig('F1slab_v1.fig');
axObjs = fig.Children;
%Since first is the colormap, select next 2 objects
dataObj1 = axObjs(2);
dataObj2 = axObjs(3);
%Based on the figure type select line, scatter, contour, etc
lineObjs = findobj(dataObj1, 'type','contour');
%Extract the x,y,z, etc data associated with the figure
xdata = get(lineObjs,'XData');
ydata = get(lineObjs,'YData');
zdata = get(lineObjs,'ZData');
Similarly, you can extract data from the second object and continue with subsequent operations or generate visualizations based on the extracted data.
For more information about MATLAB graphics object, refer to: Graphics Object Hierarchy - MATLAB & Simulink (mathworks.com).

Categorías

Más información sobre Specifying Target for Graphics Output en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by