function createPhaseDiagram()
    % Define axis values
    SCATTERING_LENGTH_RANGE = [75.00 76.09 77.18 78.27 79.36 80.00 81.04 82.08 83.12 84.17 85.21 86.25 87.29 88.33 89.38 90.42 91.46 92.50 93.54 94.58 95.62 96.67 97.71 98.75 99.79 100.83 101.88 102.92 103.96 105.00];
    NUM_ATOMS_LIST = [50000 54545 59091 63636 68182 72727 77273 81818 86364 90909 95455 100000 304167 508333 712500 916667 1120833 1325000 1529167 1733333 1937500 2141667 2345833 2550000 2754167 2958333 3162500 3366667 3570833 3775000 3979167 4183333 4387500 4591667 4795833 5000000];
    
    xlen = length(NUM_ATOMS_LIST);
    ylen = length(SCATTERING_LENGTH_RANGE);
    
    M    = zeros(ylen,xlen);  % Phase diagram matrix

    fig = figure('Name', 'Manual Phase Diagram Input', ...
                 'NumberTitle', 'off', ...
                 'KeyPressFcn', @keyCallback);
    fig = figure(1); 
    fig.WindowState = 'maximized';
    clf
    set(gcf,'Position', [100, 100, 1600, 900])
    hImg = imagesc(M);
    set(gca, 'YDir', 'normal');
    colormap(parula);
    colorbar;
    axis equal tight;
    xticks(1:xlen);
    yticks(1:ylen);
    xticklabels(string(NUM_ATOMS_LIST));
    yticklabels(string(SCATTERING_LENGTH_RANGE));
    xlabel('Number of Atoms');
    ylabel('Scattering Length (a0)');
    grid on;
    title('Click a cell to label it. Press "q" to quit.'); % Zero-temperature Phase Diagram

    set(fig, 'WindowButtonDownFcn', @clickCallback);
    uiwait(fig);  % Wait until user quits

    [filename, pathname] = uiputfile('phase_diagram_matrix.mat', 'Save Matrix As');
    if ischar(filename)
        save(fullfile(pathname, filename), 'M', 'SCATTERING_LENGTH_RANGE', 'NUM_ATOMS_LIST');
        disp(['Matrix saved to ' fullfile(pathname, filename)]);
    end

    function clickCallback(~, ~)
        C = get(gca, 'CurrentPoint');
        col = round(C(1,1));
        row = round(C(1,2));
        if row >= 1 && row <= ylen && col >= 1 && col <= xlen
            prompt = sprintf('Enter label for scattering length %.1f and N = %d:', ...
                             SCATTERING_LENGTH_RANGE(row), NUM_ATOMS_LIST(col));
            answer = inputdlg(prompt, 'Input Label', 1);
            if ~isempty(answer)
                val = str2double(answer{1});
                if ~isnan(val)
                    M(row, col) = val;
                    refreshDisplay();
                else
                    warndlg('Invalid input. Please enter a numeric value.', 'Invalid Input');
                end
            end
        end
    end

    function keyCallback(~, event)
        if strcmp(event.Key, 'q')
            uiresume(fig);
            close(fig);
        end
    end

    function refreshDisplay()
        set(hImg, 'CData', M);
        drawnow;
    end
end
