Importing and plotting with

2 views (last 30 days)
George on 8 Jan 2016
Commented: Star Strider on 8 Jan 2016
I'm trying to import into Matlab the attached data. The data along the Y axis are labelled ('electrostatic, vanderWaals, Polarsolv, etc). The data along the X axis are labelled (DE3-L73, DE3-etc) I'm trying to plot a 2- or 3D stacked bar.
If I import as a table, and then do bath(Y) I get the following error. Error using barh (line 40) Input arguments must be numeric.**
If I import as numeric matrix, I lose the X and Y axes labelling information.
I'd be grateful for any suggestions regarding how to go around this problem.
Regards George

Accepted Answer

Star Strider
Star Strider on 8 Jan 2016
I’m not quite sure what you want, but this code using bar3 will get you started:
[d,s,r] = xlsread('George DE3-DE4.csv');
Forces = s(1,2:6);
DE3s = s(2:14,1)';
grid on
yt = get(gca, 'YTick');
% xt = get(gca, 'XTick');
set(gca, 'YTick',yt, 'YTickLabel',DE3s, 'YTickLabelRotation',30)
set(gca, 'XTick',[1:length(Forces)], 'XTickLabel',Forces, 'XTickLabelRotation',-30)
It imports your data, creates your axis labels, and plots the bar3 graph, producing:
You can modify this code to get the type of bar plot you want.

Sign in to comment.

More Answers (0)


Find more on Graphics Object Properties in Help Center and File Exchange


Community Treasure Hunt

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

Start Hunting!