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

63 vues (au cours des 30 derniers jours)
Tony Castillo
Tony Castillo le 14 Jan 2019
Commenté : OCDER le 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)');

Réponse acceptée

OCDER
OCDER le 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 commentaires
Tony Castillo
Tony Castillo le 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.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur View and Analyze Simulation Results dans Help Center et File Exchange

Produits


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by