Bar plot error when plotting
Show older comments
Dear MATLAB experts,
I'm trying to create a bar plot with the column 'position_holder' in the x axis and the column 'percentage' in the y axis.
I want to only plot the first 20 rows of this two columns, but even if I explicitly create a new table with these 20 rows, MATLAB keeps on plotting all rows included in the position_holderFrequency table, when it should just be including the 20 rows from position_holderFrequencyHead.
Therefore, the plot created is all over the place and not useful at all (see attachment). I don't know if this is a problem from MATLAB itself or there is something wrong in the code written, but I would really be thankful for your guidance.
Thank you in advance.
% Plot the histogram for column 'position_holder'
figure('Name', 'Frequency of Appearance of position_holder', 'NumberTitle', 'off');
position_holderFrequency.position_holder = categorical(position_holderFrequency.position_holder);
% Need to create a new table because bar is not able to process only the
% first 20 rows
position_holderFrequencyHead = position_holderFrequency(1:20, [1 3]);
bar(position_holderFrequencyHead.position_holder, position_holderFrequencyHead.percentage);
xlabel('position_holder')
ylabel('%')
title('Distribution of position_holder Frequency')
Accepted Answer
More Answers (0)
Categories
Find more on Discrete Data Plots 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!