Plotting HSP in Matlab

I am trying to recreate a Hansen solubility sphere using Matlab. I can plot the solute sphere using:
[x,y,z] = sphere;
radius = 7.1;
x = x * radius;
y = y * radius;
z = z * radius;
x_offset = 17.0;
y_offset = 9.8;
z_offset = 9.4;
surf(x+x_offset,y+y_offset,z+z_offset)
surf(x,y,z,'FaceAlpha',0.3)
shading("interp")
colormap("summer")
xlabel('\delta_{d}', 'FontSize', 20);
ylabel('\delta_{p}', 'FontSize', 20);
zlabel('\delta_{h}', 'FontSize', 20);
axis equal;
However, I now need to be able to superimpose a 3D scatter plot on the same plot as the sphere. Any suggestions?

回答 (1 件)

Star Strider
Star Strider 2023 年 9 月 22 日

0 投票

Use the hold function —
[x,y,z] = sphere;
radius = 7.1;
x = x * radius;
y = y * radius;
z = z * radius;
x_offset = 17.0;
y_offset = 9.8;
z_offset = 9.4;
figure
surf(x+x_offset,y+y_offset,z+z_offset)
hold on
surf(x,y,z,'FaceAlpha',0.3)
hold off
shading("interp")
colormap("summer")
xlabel('\delta_{d}', 'FontSize', 20);
ylabel('\delta_{p}', 'FontSize', 20);
zlabel('\delta_{h}', 'FontSize', 20);
axis equal;
.

4 件のコメント

Peter
Peter 2023 年 9 月 25 日
Thanks - I'd tried that before but assumed I was wrong because of the appearance of two spheres - almost like the lower one is a shadow. Any idea how I can remove that so that only a single 3D sphere shows (plus the scatter plot when that's introduced).
Star Strider
Star Strider 2023 年 9 月 25 日
My pleasure!
I’m lost. I thought you wanted to plot both of them. If you don’t want the second sphere, don’t plot it, or change its offsets to plot it in a different location. If you want to change the axes limits, use xlim and its friends or axis to set all the limits at once.
For the scatter plot, use hold and the scatter3 function.
Peter
Peter 2023 年 9 月 26 日
Thanks - et voilla. Some tinkering to do with marker colour/shape, but it's not a bad approximation of what we get with bespoke sofware.
Star Strider
Star Strider 2023 年 9 月 26 日
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

サインインしてコメントする。

カテゴリ

製品

質問済み:

2023 年 9 月 22 日

コメント済み:

2023 年 9 月 26 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by