How to move colorbar in scatter3 plot and keep it inside the figure
After adding title to the colorbar of a scatter3 plot, I realized the formatting is all wonky.
Looking online, I moved the colorbar to southoutside, and was able to move the colorbar by setting its second position, see code below, but it simply moves the colorbar out of the window instead and can no longer be seen.
Based on another answer, I tried to move the axes of the scatter3 plot, since in that case, moving the axes forced the figure window to resize, but it failed – scatter3’s axes doesn’t seem to have position property, which makes sense, given the type of figure.
So I am at a loss. I could move the parts manually, and then resize the main plot area, but I would love to be able to do it with the script since I would need to process many figures like this. Does anyone have any suggestions?
importdata(‘GNDout.mat’);
x = GNDout(:,1);
y = GNDout(:,2);
z = GNDout(:,3);
value2 = GNDout(:,17)-min(GNDout(:,17));
figure;
S = 50;
scatter3(x,y,z,S,value2/1e14,’filled’);
xlabel(‘x’);
ylabel(‘y’);
zlabel(‘z’);
axis equal;
cb = colorbar(‘Location’,’Southoutside’);
cb.Position(2) = cb.Position(2)-0.5;
title(cb, ‘rho_{GND} [10^{14} m^{-2}]’);
Attached is the data GNDout. Thanks in advance!After adding title to the colorbar of a scatter3 plot, I realized the formatting is all wonky.
Looking online, I moved the colorbar to southoutside, and was able to move the colorbar by setting its second position, see code below, but it simply moves the colorbar out of the window instead and can no longer be seen.
Based on another answer, I tried to move the axes of the scatter3 plot, since in that case, moving the axes forced the figure window to resize, but it failed – scatter3’s axes doesn’t seem to have position property, which makes sense, given the type of figure.
So I am at a loss. I could move the parts manually, and then resize the main plot area, but I would love to be able to do it with the script since I would need to process many figures like this. Does anyone have any suggestions?
importdata(‘GNDout.mat’);
x = GNDout(:,1);
y = GNDout(:,2);
z = GNDout(:,3);
value2 = GNDout(:,17)-min(GNDout(:,17));
figure;
S = 50;
scatter3(x,y,z,S,value2/1e14,’filled’);
xlabel(‘x’);
ylabel(‘y’);
zlabel(‘z’);
axis equal;
cb = colorbar(‘Location’,’Southoutside’);
cb.Position(2) = cb.Position(2)-0.5;
title(cb, ‘rho_{GND} [10^{14} m^{-2}]’);
Attached is the data GNDout. Thanks in advance! After adding title to the colorbar of a scatter3 plot, I realized the formatting is all wonky.
Looking online, I moved the colorbar to southoutside, and was able to move the colorbar by setting its second position, see code below, but it simply moves the colorbar out of the window instead and can no longer be seen.
Based on another answer, I tried to move the axes of the scatter3 plot, since in that case, moving the axes forced the figure window to resize, but it failed – scatter3’s axes doesn’t seem to have position property, which makes sense, given the type of figure.
So I am at a loss. I could move the parts manually, and then resize the main plot area, but I would love to be able to do it with the script since I would need to process many figures like this. Does anyone have any suggestions?
importdata(‘GNDout.mat’);
x = GNDout(:,1);
y = GNDout(:,2);
z = GNDout(:,3);
value2 = GNDout(:,17)-min(GNDout(:,17));
figure;
S = 50;
scatter3(x,y,z,S,value2/1e14,’filled’);
xlabel(‘x’);
ylabel(‘y’);
zlabel(‘z’);
axis equal;
cb = colorbar(‘Location’,’Southoutside’);
cb.Position(2) = cb.Position(2)-0.5;
title(cb, ‘rho_{GND} [10^{14} m^{-2}]’);
Attached is the data GNDout. Thanks in advance! plotting, figure MATLAB Answers — New Questions