Displaying names vertically on the x axis
Show older comments
I am doing a school project on environmental analysis and was trying to compare various factors such as carbon emission energy consumption, forest area and population. I have managed to plot a simple 2D graph as below but am keen to place the names of the countries at the bottom of each bar vertically @ the x axis point. Would that be possible ?
Also i felt that the way i am visualizing my data is rather bad or unclear. Is there a better way like adding colored bar or using graphs or 3d scatter ?

My Code would be as below..
%1-21, 22-42, 43-63, 64-84%
combine = table(C1990, C1991, C1992, C1993, C1994, C1995, C1996, C1997, C1998, C1999, C2000, C2001, C2002, C2003, C2004, C2005, C2006, C2007, C2008, C2009, C2010,...
F1990, F1991, F1992, F1993, F1994, F1995, F1996, F1997, F1998, F1999, F2000, F2001, F2002, F2003, F2004, F2005, F2006, F2007, F2008, F2009, F2010,...
E1990, E1991, E1992, E1993, E1994, E1995, E1996, E1997, E1998, E1999, E2000, E2001, E2002, E2003, E2004, E2005, E2006, E2007, E2008, E2009, E2010,...
P1990, P1991, P1992, P1993, P1994, P1995, P1996, P1997, P1998, P1999, P2000, P2001, P2002, P2003, P2004, P2005, P2006, P2007, P2008, P2009, P2010,...
'RowNames', Country)
year = 1990:1:2010;
h1 = combine(1:59 ,:)
h2 = combine(:, { 'C1990' 'F1990' 'E1990' 'P1990' })
% Draw a bar chart for a number of variables
vars = { 'C1990' , 'F1990' , 'E1990' , 'P1990' }
ylabels = {'Carbon Emission' 'Forest Land Area' 'Energy COnsumption' 'Population'};
for i = 1: length( vars )
% field/variable names for structures/datasets must be char arrays
variable = char( vars (i) );
% dynamically reference dataset variable
data = combine.( variable );
figure;
bar( data );
set(gca,'XTickLabel',{'Afghanistan','Argentina','Australia','Austria','Belgium','Bangladesh','Brazil','Canada','Switzerland','Chile','China','Czech Republic','Germany','Denmark','Egypt','Spain','Finland','France','United Kingdom','Georgia','Greece','Hong Kong','Hungary','Indonesia','India','Ireland','Iran','Iraq','IceLand','Israel','Italy','Jamaica','Jordan','Japan','Cambodia','Sri Lanka','Maldives','Myanmar','Malaysia','Netherlands','Norway','Nepal','New Zealand','Pakistan','Peru','Philippines','Poland','Portugal','Paraguay','Russia','Saudi Arabia','Singapore','Sweden','Thailand','Turkey','Ukraine','United States','Vietnam','South Africa','World'})
title( ylabels(i) );
%xlabel( 'x' );
ylabel( ylabels(i) );
end
Accepted Answer
More Answers (0)
Categories
Find more on Labels and Annotations in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!