Add Percentage to the Bars in Tornado Plot
Show older comments
How to add the percentage of how much each value decrease and increase in the bars in Tornado plot like in this picture?
here is my code:
% Input data
Data = [
0.983 0.955 0.935;
1.006 0.955 0.920;
0.897 0.955 1.014;
1.026 0.955 0.906;
0.892 0.955 1.038;
1.058 0.955 0.888;
1.059 0.955 0.887
];
% Calculate the differences between low, base, and high values
diff_low = Data(:, 1) - Data(:, 2);
diff_high = Data(:, 3) - Data(:, 2);
% Plot tornado plot
figure;
barh([diff_low, diff_high], 'stacked');
set(gca, 'YTickLabel', {'', '1', '2', '3', '4', '5', '6' , '7'});
xlabel('% Change to LCOW from Base Case (0.955 $/m^{3})');
%ylabel('Data Point');
title('Sensitivity Analysis of CSP-RO');
legend('Decrease Cost', 'Increase Cost');
% Display grid
grid on;
% Customize axis labels
set(gca, 'YTick', 1:7);
yticklabels({'DNI, W/m² (-20%, 755, +20%)', 'Membrane lifetime, yr (-20%, 5, +20%)', 'IRR, % (-20%, 5, +20%)', 'Operating hours, hr/day (-20%, 6, +20%)', 'Seawater salinity, g/m³ (-20%, 45, +20%)', 'Plant lifetime, yr (-20%, 20, +20%)', 'Plant capacity, m³/dy (-20%, 3500, +20%)'});
Accepted Answer
More Answers (0)
Categories
Find more on Plot Customization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!