I am trying to learn gadfly plotting library. I have a very simple dataset as follows:
country,percent country1,47 country2,41 country3,39 country4,39 country5,36 country6,36 country7,36 country8,35 country9,34 country10,31 country11,31 country12,30 country13,30 country14,29 country15,29 country16,25 country17,24 country18,23 country19,22 country20,22 country21,22 country22,21 country23,21 country24,21 country25,19 country26,18 country27,18 country28,15 country29,13 country30,41 country31,38 country32,16
I am trying to create bar graph, and bars should be on the y axis and they should be horizontally displayed based on the values on x axis. X axis will show the measure of percentages
My gadfly plot command is as follows:
plot(df, x=:percent, y=:country, Geom.bar(orientation=:horizontal), Guide.ylabel("country", orientation=:vertical))
I need to polish the final graph but I could not figure out how to do it. Gadfly documentation, unfortunately is very lacking when it comes to details of the api.
The things that I want to improve or do:
Currently, bars are very thick and there are no spaces between them. I want spaces if possible. They look like overlapping even if I use
position=:dodgesetting for the bar geometry. How can I insert spaces between bars and/or make bars thinner.
I have given
color=:countryaesthetics but the resulting graph was to colorful. I want only for example two colors and bars should have those colors in alternating way to improve readability. I know that I can do it via adding a third column to the data which may have one of two values for each row and based on that I can use a
color = :Column3. I hope or believe there must be better and easier way to do it.
I would like display the values of bars at the tip or inside of them.
Any insight, help much appreciated.