Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Senegal pop with M/F ratio
|tab ds b lb |
tab := RTTabTable new input: 'http://senegalouvert.org/data/core/Population-Senegal/r/Population%20Senegal.csv' asUrl retrieveContents usingDelimiter: $,.
tab removeFirstRow.
tab convertColumnsAsFloat: #(1 2 3 4).
b := RTGrapher new.
ds := RTDataSet new.
ds interaction popup.
ds points: tab values.
ds dotShape color: (Color blue alpha: 0.3).
ds x: [ :row | (row at: 1) - 1970 ].
ds y: [ :row | row at: 3 ].
ds dotSize: [ :row | (row at: 4) - (row at: 3) ] min: 5 max: 15 using: #yourself.
b add: ds.
b axisX title: 'Year'; labelConvertion: [ :v | (v + 1970) asInteger ].
b axisY title: 'Million People'; labelConvertion: [ :v | (v / 1000000) round: 2 ].
b build.
lb := RTLegendBuilder new.
lb view: b view.
lb addText: 'Population in Senegal'.
lb build.
b view.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment