Labeling a bar graph with names in MATLAB GUI
2 次查看(过去 30 天)
显示 更早的评论
Hi there,
I am trying to plot a bar graph in MATLAB to show the power rating of appliances. The variable which hold all the appliances names and power is called databaseApps of type cell and looks like the following:
databaseApps={'tv',50;'kettle',100};
I have tried various methods to plot a bar graph in the GUI with little success:
bar(handles.axes1,databaseApps(:,1),cell2mat(databaseApps(:,2))) This just says arrays must be numeric or logic.
bar(handles.axes1,cell2mat(databaseApps(:,2)) Then tried to use the set function to set the tick labels but an error appears saying values must be handles: set(get(handles.axes1,'XTickLabel'),databaseApps(:,1));
The only thing that seems to work is if I use gca but this is risky because I have more than one axes and the labels do not line up well with the bars. Any suggestions?
Cheers
Stuart
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Bar Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!