How will change the scale value in the figure?

1 回表示 (過去 30 日間)
AZ Sajjad
AZ Sajjad 2022 年 11 月 22 日
コメント済み: AZ Sajjad 2022 年 11 月 22 日
I have marked blue colors in the figure below. There I want to change the scale value on the y-axis.
How do I do 6.0x10^6 instead of 4.5x10^5 here?
I have written the code below for better understanding.
clc;
close all;
clear;
figure
components = {'DG', 'PV', 'Converter', 'Battery'};
y = [445000, 160777, 108888, 265153];
hB = bar(y,'FaceColor','flat');
xticklabels(components);
C = colororder; % retrieve default colororder vector
hB.CData = C(1:numel(y),:); % use first N
grid on
xlabel ('Components Name','fontweight','bold','FontSize',12);
ylabel ('Net Present Cost ($)','fontweight','bold','FontSize',12);
hAx = gca; % get current axes handle
hAx.YAxis.TickLabelFormat = '%0.1f'; % fix up the funky numeric display
% now add a legend by faking another plot that will create the handles
hold on
hA = area(nan(numel(components))); % area will be patch
set(hA,{'FaceColor'},mat2cell(hB.CData,[ones(size(y))],3)); % set areas to match bar face colors
hLg = legend(hA,components);
6x10^6 instead of 4.5x10^5 here

採用された回答

KSSV
KSSV 2022 年 11 月 22 日
Read about ylim
ylim([0 6*10^6])
  1 件のコメント
AZ Sajjad
AZ Sajjad 2022 年 11 月 22 日
A lot of thanks, sir, for giving your precious time.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by