How to set the whole values in the "y" axis?

63 Ansichten (letzte 30 Tage)
Tony Castillo
Tony Castillo am 14 Jan. 2019
Kommentiert: OCDER am 15 Jan. 2019
Hi dear MATLAB community,.
I want to ask you how to portray in the Y axis the whole number (quantity), not as appear in my code, which is based on engineering format, do you know how to do it?.
Thanks in advance
clear all
close all
%%%%Price in every part of the components of the facility
Panels=230000;
Batteries=123000;
MPP=15000;
Maintenance=116000;
OtherExpenses=73000;
Transformer=4000;
c = categorical({'Panels','Batteries','MPP','Maintenance','OtherExpenses'});
X = [Panels,Batteries,MPP,Maintenance,OtherExpenses];
%%%subplot one
ax1 = subplot(1,2,1);
p1=bar(ax1,c,X);
title(ax1,'PV facility cost (models B&C)');
%%%%subplot two
c1 = categorical({'Batteries','Transformer','Maintenance','OtherExpenses'});
Y = [Batteries,Transformer,Maintenance,OtherExpenses];
ax2 = subplot(1,2,2);
p2=bar(ax2,c1,Y);
title(ax2,'Fossil facility cost (model A)');

Akzeptierte Antwort

OCDER
OCDER am 14 Jan. 2019
See post about adjusting the axes YRuler and XRuler properties.
ax = gca;
ax.YRuler.Exponent = 0;
Your code:
%%%%Price in every part of the components of the facility
Panels=230000;
Batteries=123000;
MPP=15000;
Maintenance=116000;
OtherExpenses=73000;
Transformer=4000;
c = categorical({'Panels','Batteries','MPP','Maintenance','OtherExpenses'});
X = [Panels,Batteries,MPP,Maintenance,OtherExpenses];
%%%subplot one
ax1 = subplot(1,2,1);
p1=bar(ax1,c,X);
title(ax1,'PV facility cost (models B&C)');
ax1.YRuler.Exponent = 0; %ADD THIS !!!
%%%%subplot two
c1 = categorical({'Batteries','Transformer','Maintenance','OtherExpenses'});
Y = [Batteries,Transformer,Maintenance,OtherExpenses];
ax2 = subplot(1,2,2);
p2=bar(ax2,c1,Y);
title(ax2,'Fossil facility cost (model A)');
ax2.YRuler.Exponent = 0; %ADD THIS !!!
  3 Kommentare
Tony Castillo
Tony Castillo am 15 Jan. 2019
Do you know how to add a value in the top of each column?, because I want adding the respective percentage in the bar graph.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu View and Analyze Simulation Results finden Sie in Help Center und File Exchange

Produkte


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by