Plotting a 4D graph with the fourth dimension using color (a 3D graph with the fourth dimension represented using colors)
Show older comments
I would like to know how to plot R0 (basic reproduction number of a disease) against three given parameters on a 3D plot where the x-, y-, and z- axes represent the three parameters and a color scheme represents R0. So, the graph should essentially be a 3D plot, but the fourth dimension (depicting R0) should be in terms of a color scheme.
In the current example, I wish to plot R0 against the three parameters beta, p, and phi which could all vary between 0 and 1. The formula for R0 and the parameters are given below.
c = 0.01;
%beta = 0.4;
gamma = 0.2;
theta = 0.2778;
%p = 0.05;
%phi = 0.95;
epsilon = 0.084;
delta = 0.011;
mu = 0.000027;
R0 = (epsilon*c*beta*theta*(mu+(1-phi)*p))/(mu*(mu+p)*(mu+epsilon)*(mu+gamma+delta))
I would highly appreciate if someone could help me on this. Thanks a lot in advance!
Answers (1)
Use "slice".
This will display R0 on predefined planes in 3d space.
12 Comments
Torsten
on 15 Jan 2023
You told MATLAB to plot R0 on six slices (beta=0, beta=0.1, beta=1, p=0.5, phi=0, phi=0.2) and it did.
What do you mean by "restrict R0 to be less than 5" ? You want to plot min(R0,5) ?
Bas123
on 15 Jan 2023
Torsten
on 15 Jan 2023
This is a surface plot for "Intensity" depending on two instead of three parameters. One is radius, the other axis has no name.
Use "surf" to get a plot like the one above.
Since the values for "Intensity" are between -10 and 10, it's probable that you did some mistake in the definition of R0 or that you used a different unit for "Intensity" than in the above graphics.
Bas123
on 15 Jan 2023
Torsten
on 15 Jan 2023
It might also be the plot of a fourth variable on a surface different from a plane. But it's unclear how the surface was created and what it represents. Maybe it's an isosurface of another variable - only you know.
Bas123
on 17 Jan 2023
If values for R0 are computed to be greater than 5, then how do you want to plot them ?
You could set the R0 values > 5 to NaN values. These values are not plotted afterwards.
Or you could set them artificially to 5.
But isn't that simply cheating ?
Bas123
on 17 Jan 2023
Torsten
on 17 Jan 2023
But if your model for R0 gives non-meaningful values, you should start modifying your model instead of modifying the results from the model, shouldn't you ?
Bas123
on 17 Jan 2023
Categories
Find more on 2-D and 3-D Plots 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!

