How to show categorical data on x-axis when using bar function?

前端 未结 1 638
青春惊慌失措
青春惊慌失措 2021-01-23 20:26

I am trying to simulate a code which is on the official MATLAB website, but I cannot get the same output.

This is the code:

c = categorical({\'apples\',         


        
相关标签:
1条回答
  • 2021-01-23 20:59

    You can try the following workaround (as mentioned here):

    prices = [1.23 0.99 2.3];
    bar(prices)
    set(gca,'xticklabel',{'apples','oranges','pears'});
    

    So, you get rid of categorical and switch to the gca function, that allows you to change axis labels.

    0 讨论(0)
提交回复
热议问题