Include the name of each category in x-axis in a Plot

3 views (last 30 days)
Can anyone please help me on how to show the name of each category on a MATLAB plot. I know I can do it on a Bar chart but I need to use plot instead. I have tried to use categorical but when I changed their names, the graph was plotted wrongly. This what I have
if true
% code
c = categorical({'M';'M+2S';'M+S';'M-2S';'M-S';'P10';'P50';'P90'});
Objective_Rank rand(1,8)
plot(c,Objective_Rank))
end
I found later I wanted to name the category with different name such as {'2M';'M+S';'M+2S';'M-2S';'M-S';'P10';'P50';'P90'} after I have changed the Objective_Rank's elements positions. Can anyone help please.

Accepted Answer

Yaser Khojah
Yaser Khojah on 8 Oct 2018
if true
% code
f(j) = figure;
% Create axes
axes1 = axes('Parent',f(j));
hold(axes1,'on');
plot(Objective_Rank(j,:))
title(['Demand ' num2str(Demand) ' MMSCFD - Reservoir Uncertaintiy with ' num2str(Percent(j)) '% STD (Log Normal)'])
box(axes1,'on');
% Set the remaining axes properties
set(axes1,'XTick',[1 2 3 4 5 6 7 8],'XTickLabel',...
{'M-2S','P10','M-S','M','P50','M+S','P90','M+2S'});
end

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!