# Scatter Plot with string in x-axis and integer on y-axis

21 views (last 30 days)
Mahaveer Uttamchand on 22 Jul 2019
Commented: TADA on 22 Jul 2019
My data is
samples=["4S1";"4S2";"4S3";"4S4";"4S5"]';
percentage=[0;-11.5000000000000;-2.44000000000000;-8.13000000000000;-2.44000000000000]';
scatter(samples,percentage);
Error Message:
Error using scatter (line 56)
Input arguments must be numeric, datetime, duration or categorical.
Can anyone please help?
##### 2 CommentsShowHide 1 older comment
Mahaveer Uttamchand on 22 Jul 2019
Thank you KALYAN ACHARJYA for your answer, however, please check my answer that I posted recently. Have a good day. Thank you once again :)

Sign in to comment.

### Accepted Answer

Mahaveer Uttamchand on 22 Jul 2019
I had found myself recently, actually as mentioned in the error, it should be categorical,
Here is the program,
n=["4S1";"4S2";"4S3";"4S4";"4S5"]';
y=[0;-11.5000000000000;-2.44000000000000;-8.13000000000000;-2.44000000000000]';
x=categorical(n);
s=scatter(x,y);
and if you want your graph to look nice, use the following,
s.LineWidth = 0.6;
s.MarkerEdgeColor = 'b';
s.MarkerFaceColor = [0 0.5 0.5];
##### 2 CommentsShowHide 1 older comment
TADA on 22 Jul 2019
Elegant solution +1 from me

Sign in to comment.

### More Answers (1)

TADA on 22 Jul 2019
Maybe bar chart would be better for you, but if you must use scatter plot
scatter(1:5,percentage);
set(gca, 'XTick', 1:5, 'XTickLabel', samples);
##### 2 CommentsShowHide 1 older comment
Mahaveer Uttamchand on 22 Jul 2019
Thank you TADA for your answer, however, please check my answer that I posted recently. Have a good day. Thank you once again :)

Sign in to comment.

### Community Treasure Hunt

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

Start Hunting!