MATLAB Answers

Plot a bar chart while sorting its variables and presenting the cosponsoring new sorted variables in the x-axis.

1 view (last 30 days)
Yaser Khojah
Yaser Khojah on 25 Feb 2019
Answered: Yaser Khojah on 25 Feb 2019
I have two vectors as below where i would like to plot them in a bar chart in a descending order while showing the corropsoing values in the x-axix. However, my plot does not look nice as attached. Is there any way to fix it please.
fields_name = 1:19;
CV = [8 68 30 14 9 13 28 17 13 29 23 17 41 27 25 51 0 20 28];
[CV_Sorted,index] = sort(CV,'descend');
bar(CV_Sorted)
yt = get(gca, 'xTick');
set(gca, 'xTick',yt, 'xTickLabel',Fields_Sorte)

  0 Comments

Sign in to comment.

Accepted Answer

Yaser Khojah
Yaser Khojah on 25 Feb 2019
Cases = 1:19;
[CV_Sorted,index] = sort(CV,'descend');
bar(CV(index))
xTick = Fields_Sorte;
set(gca, 'xTick',Cases, 'xTickLabel',Fields_Sorte)

  0 Comments

Sign in to comment.

More Answers (0)

Sign in to answer this question.

Tags