I want to create a bar3 plot for the contribution of two parameters as like in figure

3 views (last 30 days)
I already obtained the correct form of the plot but magnitude and distance values are not in true position. As can bee seen from the figure, magnitude values in left figure are not in the same position with the right figure as well distance values. How to overcome from this problem? I already tried to change it in browser but it will not worth it because I have a lot of data that I need to obtain this plot. As an example, in second figure I shared the contribution of the two parameters in table.
and here is what I did in matlab:

Sign in to comment.

Answers (2)

Cris LaPierre
Cris LaPierre on 10 Aug 2022
I see what you are saying. Magnitude corresponds to your Y axis, which corresponds to the rows of B. In the file, they increase from 4.55 to 9.45, but in your bar chart, they go from 4.55 to 5.05. This is because the labels are belng added to the tick locations MATLAB automatically selected. To get the output you want, you need to first set the tick locations.
However, this is unnecessary here. Use the following syntax to get the correct values on Y. Then you just need to update X ticks.
load B.mat
X = B(2,3:end); % columns of matrix
Y = B(3:end,2); % Rows of matrix
data = B(3:end,3:end);
xticks(X) % Just to be safe, set the tick locations to be what you are expecting them to be

dpb on 10 Aug 2022
OK...had a few minutes -- try
Z=B(3:end,3:end); % save the data portion of the overall arrray; MATLAB will, I think) just create reference
Y=B(3:end,2); % get the coordinate data
ylim([Y(1) Y(end)]) % show only range of Y
which sets the X and Y axis tick labels to the actual ranges.
You can't see the particular values you're mentioning because the preceding rows occlude the smaller middle rows at that orientation; if you rotate so can "look" between those row, you'll be able to see the values are there.

Community Treasure Hunt

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

Start Hunting!