12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- % Define the data points
- mouse_days = [0, 3, 14, 21, 28, 48];
- human_days = [0, 1, 7, 90, 180, 360];
- phases = {'Hyper-acute', 'Acute', 'Early Subacute', 'Late Subacute', 'Chronic'};
- phase_colors = [0.8, 0.2, 0.2; % Hyper-acute
- 0.2, 0.8, 0.2; % Acute
- 0.2, 0.2, 0.8; % Early Subacute
- 0.8, 0.8, 0.2; % Late Subacute
- 0.5, 0.2, 0.5]; % Chronic
- % Create a spline fit
- spline_fit = spline(mouse_days, human_days);
- % Generate finer x values for smooth curve plotting
- fine_mouse_days = linspace(min(mouse_days), max(mouse_days), 100);
- fine_human_days = ppval(spline_fit, fine_mouse_days);
- % Plot the data points and the fit
- figure;
- hold on;
- plot(mouse_days, human_days, 'o', 'MarkerFaceColor', 'b', 'DisplayName', 'Data Points');
- plot(fine_mouse_days, fine_human_days, '-r', 'DisplayName', 'Spline Fit');
- % Fill areas under the curve according to phases
- for i = 1:length(mouse_days)-1
- fill_x = [mouse_days(i), linspace(mouse_days(i), mouse_days(i+1), 100), mouse_days(i+1)];
- fill_y = [0, ppval(spline_fit, linspace(mouse_days(i), mouse_days(i+1), 100)), 0];
- fill(fill_x, fill_y, phase_colors(i,:), 'FaceAlpha', 0.5, 'EdgeColor', 'none');
-
- % Write the phases in the areas between time points
- mid_x = (mouse_days(i) + mouse_days(i+1)) / 2;
- mid_y = ppval(spline_fit, mid_x) / 2;
- text(mid_x, mid_y, phases{i}, 'HorizontalAlignment', 'center', 'FontSize', 12, 'Color', 'k');
- end
- % Add dashed grey lines from data points to x and y ticks
- for i = 1:length(mouse_days)
- x = mouse_days(i);
- y = human_days(i);
- plot([x, x], [0, y], '--', 'Color', [0.5, 0.5, 0.5]);
- plot([0, x], [y, y], '--', 'Color', [0.5, 0.5, 0.5]);
- end
- % Set the ticks for the dashed lines
- set(gca, 'XTick', mouse_days);
- set(gca, 'YTick', human_days);
- % Add legend and labels
- xlabel('Mouse Days');
- ylabel('Human Days');
- title('Mouse Days to Human Days Conversion');
- % Remove the legend
- legend off;
- % Show grid for better visualization
- grid on;
- hold off;
|