Skip to content

Commit

Permalink
Allow different parameters to plot for survival
Browse files Browse the repository at this point in the history
  • Loading branch information
kwang428 committed Jan 22, 2025
1 parent e590389 commit 442425e
Showing 1 changed file with 34 additions and 10 deletions.
44 changes: 34 additions & 10 deletions PlotProcessTools.m
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,29 @@ function plotSurvival(figInfo, unique_params, surv_prob, surv_err, survival_logi
param_name_unit = figInfo.param_name_unit('');
fname = figInfo.fname('');
num_survival = size(surv_prob{1}, 1);

%% Block for determining unique_params for plotting x axis

% for unique_params, backwards compatibility, check if not a
% cell array for each image
if ~iscell(unique_params)
unique_params_temp = cell(1, num_survival);
for i = 1:num_loading
unique_params_temp{i} = unique_params;
end
unique_params = unique_params_temp;
end
% same for param_name_unit
if ~iscell(param_name_unit)
param_name_unit_temp = cell(1, num_survival);
for i = 1:num_loading
param_name_unit_temp{i} = param_name_unit;
end
param_name_unit = param_name_unit_temp;
end
num_params = length(unique_params{1});

%% Block for choosing sites to plot
if ~iscell(site_idx)
tmpIdx = cell(num_survival,1);
for i = 1:num_survival
Expand All @@ -301,10 +323,12 @@ function plotSurvival(figInfo, unique_params, surv_prob, surv_err, survival_logi
num_sites(i) = length(site_idx{i});
end

%%
ColorSet = nacstools.display.varycolorrainbow(max(num_sites));
ncol = num_survival;
nrow = 1;
for n = 1 : num_survival
for n = 1:num_survival
this_unique_params = unique_params{n};
if num_sites(n) > 0
subplot(nrow, ncol, (nrow-1)*ncol+n); hold on;
title({['survive: image ' logical_cond_2str(survival_logical_cond{n}, single_atom_species)], ...
Expand All @@ -313,37 +337,37 @@ function plotSurvival(figInfo, unique_params, surv_prob, surv_err, survival_logi
%legend_string3n1{num_sites+1} = '';
legend_string3n1{num_sites(n)} = ''; %if not plotting average
for i = 1:num_sites(n)
errorbar(unique_params/plot_scale, squeeze(surv_prob{site_idx{n}(i)}(n,:)), ...
errorbar(this_unique_params/plot_scale, squeeze(surv_prob{site_idx{n}(i)}(n,:)), ...
surv_err{site_idx{n}(i)}(n,:), 'Color', ColorSet(i,:),'Linewidth',1.0);
legend_string3n1{i} = ['site #',num2str(site_idx{n}(i))];
end
hold off;

ylim([0 1])
if length(unique_params) > 1
lims = sort([unique_params(1)- 0.1*(unique_params(end)-unique_params(1)), unique_params(end)+ 0.1*(unique_params(end)-unique_params(1))]/plot_scale);
if length(this_unique_params) > 1
lims = sort([this_unique_params(1)- 0.1*(this_unique_params(end)-this_unique_params(1)), this_unique_params(end)+ 0.1*(this_unique_params(end)-this_unique_params(1))]/plot_scale);
xlim(lims);
end
grid on; box on;
if n == cld(num_survival, 2)
xlabel({param_name_unit, fname}, 'interpreter', 'none')
xlabel({param_name_unit{n}, fname}, 'interpreter', 'none')
else
xlabel({param_name_unit})
xlabel({param_name_unit{n}})
end
ylabel('Survival probability')
legend(legend_string3n1)
end

ylim([0 1])
if length(unique_params) > 1
lims = sort([unique_params(1)- 0.1*(unique_params(end)-unique_params(1)), unique_params(end)+ 0.1*(unique_params(end)-unique_params(1))]/plot_scale);
if length(this_unique_params) > 1
lims = sort([this_unique_params(1)- 0.1*(this_unique_params(end)-this_unique_params(1)), this_unique_params(end)+ 0.1*(this_unique_params(end)-this_unique_params(1))]/plot_scale);
xlim(lims);
end
grid on; box on;
if n == cld(num_survival, 2)
xlabel({param_name_unit, fname}, 'interpreter','none')
xlabel({param_name_unit{n}, fname}, 'interpreter','none')
else
xlabel({param_name_unit})
xlabel({param_name_unit{n}})
end
ylabel('Survival probability')
title({['survive: ' logical_cond_2str(survival_logical_cond{n}, single_atom_species)], ...
Expand Down

0 comments on commit 442425e

Please sign in to comment.