Reputation: 11
I used the following code to produce a side-by-side bar chart
IT=c(0.588, 0.765)
GE=c(0.214, 0.63)
FR=c(0.316, 0.356)
PO=c(0.692,0.793)
UK=c(0.381, 0.757)
NE=c(0.227, 0.62)
GR=c(0.692, 0.902)
HU=c(0.706, 0.698)
SW=c(0.143, 0.493)
# combine two vectors using cbind
# function
CountryChart=cbind(IT,GE,FR,PO,UK,NE,GR,HU,SW)
# pass this college_data to the
# barplot
barplot(CountryChart,beside=T)
and it produce a graph with the correct data, however the y-axis is too short as it only goes from 0 to 0.8 and not to 1. The country labels are also not all displayed on the x-axis. Only four country codes are displayed so I would like to adjust the code so that it would display the code of each country below its bars.
Here's the graph I was able to produce:
Any idea on what to do to adjust the scale size of y-axis and display all country codes on the x-axis?
Upvotes: 1
Views: 162
Reputation: 173793
To get the y axis to go to 1, add ylim = c(0, 1)
in the barplot
call:
barplot(CountryChart,beside=T, ylim = c(0, 1))
To make all your countries appear on the x axis, you need to realise that the plot is suppressing some of the labels to prevent them from overlapping. To fix this, you can shrink the x label sizes:
barplot(CountryChart,beside=T, ylim = c(0, 1), cex.names = 0.75)
Or simply drag your plotting window to make it wider:
barplot(CountryChart,beside=T, ylim = c(0, 1))
Upvotes: 0