error bar on the graph
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
hi
after i have plot between x y and z ( scatter3(x, y, z))
x=[2.6,5.2,14,23.3,28.3,2.6,5.2,14,23.3,28.3,2.6,5.2,14,23.3,28.3];
y=[3.5,6.9,17.7,29.1,35.2,3.5,6.8,17.5,28.7,34.8,3.4,6.6,16.9,27.6,33.5];
z=[450,450,450,450,450,350,350,350,350,350,250,250,250,250,250];
i want to make error bar for y in the same graph
and i have the standard deviation for y
which is ( 0.047140452, 0.047140452, 0.047140452, 0.124721913, 0.047140452, 0.047140452, 0.047140452, 0.047140452, 0.124721913, 0.124721913, 0.047140452, 0.047140452, 0.047140452, 0.124721913, 0.124721913)
so could you tell me what is the code for that
채택된 답변
Star Strider
2020년 4월 21일
0 개 추천
The error bars are difficult to see, so I multiplied them by 10 here:
x=[2.6,5.2,14,23.3,28.3,2.6,5.2,14,23.3,28.3,2.6,5.2,14,23.3,28.3];
y=[3.5,6.9,17.7,29.1,35.2,3.5,6.8,17.5,28.7,34.8,3.4,6.6,16.9,27.6,33.5];
z=[450,450,450,450,450,350,350,350,350,350,250,250,250,250,250];
ysd = [0.047140452, 0.047140452, 0.047140452, 0.124721913, 0.047140452, 0.047140452, 0.047140452, 0.047140452, 0.124721913, 0.124721913, 0.047140452, 0.047140452, 0.047140452, 0.124721913, 0.124721913];
xr = reshape(x, [], 3);
yr = reshape(y, [], 3);
zr = reshape(z, [], 3);
ysdr = reshape(ysd, [], 3)*10;
figure
hold on
for k1 = 1:size(xr,2)
for k2 = 1:size(xr,1)
plot3((xr(k2,k1)*[1 1]), (yr(k2,k1)+ysdr(k2,k1)*[-1 1]), (yr(2,k1)*[1 1]), '-r')
plot3((xr(k2,k1)), (yr(k2,k1)), (yr(2,k1)), '.r')
end
end
hold off
view(-60,30)
grid on
xlabel('X')
ylabel('Y')
zlabel('Z')
% legend('Y\pm10\sigma')
Experiment to get the result you want.
댓글 수: 16
ahmad albngali
2020년 4월 22일
thank you so much
i have anothet question related to previouse one
know i have all x values x=[2.6,5.2,14,23.3,28.3,2.6,5.2,14,23.3,28.3,2.6,5.2,14,23.3,28.3];
and i have y values y=[3.5,6.9,17.7,29.1,35.2,3.5,6.8,17.5,28.7,34.8,3.4,6.6,16.9,27.6,33.5];
and i have z values z=[450,450,450,450,450,350,350,350,350,350,250,250,250,250,250];
so if i have
Z = 300
x = 20
Y = ???
to bring y i used the code in the bottom
YfromXZ = scatteredInterpolant(x(:), z(:), y(:))
queryx = 20;
queryz = 300;
matchingy = YfromXZ(queryx, queryz);
figure;scatter3(x, y, z); hold('on'); plot3(queryx, matchingy, queryz, 'r*');
my question is
is there any code to bring the error bar for new value for Y that related to Z = 300, x = 20 ?????
Star Strider
2020년 4월 22일
As always, my pleasure!
‘my question is: is there any code to bring the error bar for new value for Y that related to Z = 300, x = 20 ?????’
There is. However that is so far from your data that I doubt the validity of the result.
I added ExtrapolationMethod to your code in order to induce it to extrapolate:
YfromXZ = scatteredInterpolant(x(:), z(:), y(:));
queryx = 20;
queryz = 300;
YfromXZ.ExtrapolationMethod = 'linear';
matchingy = YfromXZ(queryx, queryz);
Then the approach I took was a variation on your code:
errYfromXZ = scatteredInterpolant(x(:), z(:), y(:)+ysd(:));
errYfromXZ.ExtrapolationMethod = 'linear';
matchingyerr = errYfromXZ(queryx, queryz);
errY = (matchingyerr - matchingy)
producing:
errY =
0.097193007483870
That is appropriately larger than the ‘ysd’ values, however even at that I am not certain I would trust it.
.
ahmad albngali
2020년 4월 23일
yes that what i want , and dont warry i will not trust it. ,
i know i am asking alo , but you rally help me
know i want to bring the error bar for both ( 1- all y values , 2- the new value for Y that related to Z = 300, x = 20 ) in one figure
i have attached an example of figure for x, y, z and alo a new value of Y when Z = 300, x = 20
so could you tell me the code that add a error bar for all y values and Y value as wll in the same figure


Star Strider
2020년 4월 23일
With the extrapolated values, reshape will not work (added points must correspond to the existing (5x3) format), so the code needs to be rearranged slightly and the extrapolated values plotted separately, after the plotting loop:
x=[2.6,5.2,14,23.3,28.3,2.6,5.2,14,23.3,28.3,2.6,5.2,14,23.3,28.3];
y=[3.5,6.9,17.7,29.1,35.2,3.5,6.8,17.5,28.7,34.8,3.4,6.6,16.9,27.6,33.5];
z=[450,450,450,450,450,350,350,350,350,350,250,250,250,250,250];
ysd = [0.047140452, 0.047140452, 0.047140452, 0.124721913, 0.047140452, 0.047140452, 0.047140452, 0.047140452, 0.124721913, 0.124721913, 0.047140452, 0.047140452, 0.047140452, 0.124721913, 0.124721913];
xr = reshape(x, [], 3);
yr = reshape(y, [], 3);
zr = reshape(z, [], 3);
ysdr = reshape(ysd, [], 3)*10;
YfromXZ = scatteredInterpolant(x(:), z(:), y(:));
queryx = 20;
queryz = 300;
YfromXZ.ExtrapolationMethod = 'linear';
matchingy = YfromXZ(queryx, queryz);
figure;scatter3(x, y, z); hold('on'); plot3(queryx, matchingy, queryz, 'r*');
errYfromXZ = scatteredInterpolant(x(:), z(:), y(:)+ysd(:));
errYfromXZ.ExtrapolationMethod = 'linear';
matchingyerr = errYfromXZ(queryx, queryz);
errY = (matchingyerr - matchingy)
figure
hold on
for k1 = 1:size(xr,2)
for k2 = 1:size(xr,1)
plot3((xr(k2,k1)*[1 1]), (yr(k2,k1)+ysdr(k2,k1)*[-1 1]), (yr(2,k1)*[1 1]), '-r')
plot3((xr(k2,k1)), (yr(k2,k1)), (yr(2,k1)), '.r')
end
end
plot3(queryx*[1 1], matchingy+errY*[-1 1]*10, queryz*[1 1], '-g') % <- Added
plot3(queryx, matchingy, queryz, '.g') % <- Added
hold off
view(-60,30)
grid on
xlabel('X')
ylabel('Y')
zlabel('Z')
The extrapolated point and errorbar are plotted in green to make them more visible. (All the errorbars are multiplied by 10 because they would not otherwise be visible.)
.
ahmad albngali
2020년 4월 24일
something was wrong with z values in figher 2 in attachment
for figher 1 ( attached as well ) the z was right , but for figure 2 the all values of z from 6.6 to 6.9 and this are wrong , shold be from 250 to 450 ( as figher 1 )
and the z value for Y was right in figure 2 , because as you can see the z 300 , but all z values for x and y in figure 2 are wrong
i am tring to find why this happens , but i cant do you have any idea


Star Strider
2020년 4월 24일
When I went back and looked at my most recent code, I realize there was a typographical error I did not catch. The plot3 calls should be:
plot3((xr(k2,k1)*[1 1]), (yr(k2,k1)+ysdr(k2,k1)*[-1 1]), (zr(2,k1)*[1 1]), '-r')
plot3((xr(k2,k1)), (yr(k2,k1)), (zr(2,k1)), '.r')
I copied the ‘xr’ part of those to the z position to avoid re-typing them, and then mistyped ‘yr’ instead of ‘zr’. I was concentrating on getting the error bars to plot correctly, and overlooked that.
Fixed now. The plot3 calls after the loop are correct.
ahmad albngali
2020년 4월 24일
yes , now working great
thank you so much
is there any solution to show the error bar appear in the figure without multiplied by 10
Star Strider
2020년 4월 24일
As always, my pleasure!
The error bars are there, however they are so small with respect to the amplitudes of the other variables that they are essentially impossible to see without zooming in on each plotted data point. I multiplied them by 10 to check the code to be certain they are plotting correctly. It is not necessary to multiply them at all.
ahmad albngali
2020년 4월 24일
But if I want to put it In my thesis And I want to show people the error bar I have to multiplied by 10 Right ? That was my question is there any other cases to show the error bar without multiplied by 10 Show him the right data without multiplied by 10
Star Strider
2020년 4월 24일
Just put in the legend that the errorbars aare multiplied by 10 (or whatever number you choose), since the relative sizes may be more important than the absolute sizes, depending on what you are demonstrating. I am not certain how best to show the error bars without multiplying them.
Note that this line:
plot3((xr(k2,k1)), (yr(k2,k1)), (zr(2,k1)), '.r')
puts a ‘.’ in the centre of the errorbars to show where it is. One possibility is to replace that by a ‘+’, although just leaving those out might work as well, so that only the error bars themselves are presented. One way to multiply them might be to use 1.96 (to show them as the 95% confidence intervals from the normal distribution) or the result of tinv since that might be more appropriate (and likely larger than 1.96), or confidence intervals based on another distribution, depending on what that distribution is (since I do not know what the data themselves represent).
ahmad albngali
2020년 6월 16일
hi as you remember i used this code
This code was used to find the Relationship of DEq, CTDIvol and scanning length, also the code was used to show the error bar for DEqvalues (The error bars for all DEqvalues are difficult to see in the graph , so I multiplied them by 5)
% x= CTDIv
x=[2.6,5.2,14,23.3,28.3,2.6,5.2,14,23.3,28.3,2.6,5.2,14,23.3,28.3 ];
% y= planar average equilibrium dose (DEq)
y=[3.5,6.9,17.7,29.1,35.2,3.5,6.8,17.5,28.7,34.8,3.4,6.6,16.9,27.6,33.5 ];
% z= scanning length
z=[450,450,450,450,450,350,350,350,350,350,250,250,250,250,250];
% ysd= DEq standard deviation
ysd = [0.047140452, 0.047140452, 0.047140452, 0.124721913, 0.047140452, 0.047140452, 0.047140452, 0.047140452, 0.124721913, 0.124721913, 0.047140452, 0.047140452, 0.047140452, 0.124721913, 0.124721913];
xr = reshape(x, [], 3);
yr = reshape(y, [], 3);
zr = reshape(z, [], 3);
ysdr = reshape(ysd, [], 3)*5;
%for visualisation
figure
hold on
for k1 = 1:size(xr,2)
for k2 = 1:size(xr,1)
plot3((xr(k2,k1)*[1 1]), (yr(k2,k1)+ysdr(k2,k1)*[-1 1]), (zr(2,k1)*[1 1]), '-r')
plot3((xr(k2,k1)), (yr(k2,k1)), (zr(2,k1)), '.r')
end
end
hold off
view(-60,30)
grid on
so my question
the Error bars are too small. and i want to Increase the dot size and fit a grid or lines to the dots ??
Star Strider
2020년 6월 16일
Experiment with the 'LineWidth' and 'MarkerSize' properties to get the result you want.
ahmad albngali
2020년 6월 16일
Where I have to put the 'LineWidth' and 'MarkerSize' in the code Can you add it to me in the code ?
Star Strider
2020년 6월 17일
ahmad albngali
2020년 6월 22일
hi i try to do it but it is confusing
could you please show me hoe i do it in my examble ( in my code )
Star Strider
2020년 6월 22일
Add them to the plot3 calls:
plot3((xr(k2,k1)*[1 1]), (yr(k2,k1)+ysdr(k2,k1)*[-1 1]), (zr(2,k1)*[1 1]), '-r', 'LineWidth',1.5)
plot3((xr(k2,k1)), (yr(k2,k1)), (zr(2,k1)), '.r', 'MarkerSize',10)
so the complete code is now:
% x= CTDIv
x=[2.6,5.2,14,23.3,28.3,2.6,5.2,14,23.3,28.3,2.6,5.2,14,23.3,28.3 ];
% y= planar average equilibrium dose (DEq)
y=[3.5,6.9,17.7,29.1,35.2,3.5,6.8,17.5,28.7,34.8,3.4,6.6,16.9,27.6,33.5 ];
% z= scanning length
z=[450,450,450,450,450,350,350,350,350,350,250,250,250,250,250];
% ysd= DEq standard deviation
ysd = [0.047140452, 0.047140452, 0.047140452, 0.124721913, 0.047140452, 0.047140452, 0.047140452, 0.047140452, 0.124721913, 0.124721913, 0.047140452, 0.047140452, 0.047140452, 0.124721913, 0.124721913];
xr = reshape(x, [], 3);
yr = reshape(y, [], 3);
zr = reshape(z, [], 3);
ysdr = reshape(ysd, [], 3)*5;
%for visualisation
figure
hold on
for k1 = 1:size(xr,2)
for k2 = 1:size(xr,1)
plot3((xr(k2,k1)*[1 1]), (yr(k2,k1)+ysdr(k2,k1)*[-1 1]), (zr(2,k1)*[1 1]), '-r', 'LineWidth',1.5)
plot3((xr(k2,k1)), (yr(k2,k1)), (zr(2,k1)), '.r', 'MarkerSize',10)
end
end
hold off
view(-60,30)
grid on
Change the values to create the result you want.
.
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
