How to change the xticketlabe of a bar chat
Show older comments
I have two matrixes (x and y) that I want to plot using the bar chart.
i just want to make the first bar in the plot on zero instead of 1, the next one one 1 and so on. In addition, how to make these bars wider, while keeping them sepearte. Anyway to change the bar color according to an index matrix? Could you please help.
Moreover, anyway to present this better as showing a timeline goes from year 0 to year 20 in the x-axis. Then, each bar showing the field that start in the same year. For example, in the first bar, I have three fields that start on the same day as Field 1, 2 and 8. In my plot in the first year or bar, I have them but not sure how to make them presented better as saying "Field1, Field 2 and Field 8)

x = 0:20; % the time horizon
A = repmat(x,3,1);
% y name of the field that start on the year. For example Field 1 start in year zero, Field 2 start in year 0; Field 8 in year zero; etc
y = 1 0 0 0 0 0 0 0 3 0 6 7 0 0 4 0 0 0 5 0 0
2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
figure
bar(y','stacked');
xlabel('Years')
ylabel('Field Name')
xlim([0 20])
Accepted Answer
More Answers (0)
Categories
Find more on Bar 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!