Group Abstract Group Abstract

Message Boards Message Boards

0
|
3.7K Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

BarChart using EntityList?

Posted 4 years ago

Trying to make a barchart, but not sure what I am doing wrong. I attached my code and the example,

Please advise.

POSTED BY: Jon Locke
2 Replies
Posted 4 years ago

You asked a related question yesterday but it was deleted before I could answer.

greenhouseGases = EntityClass["Chemical", "GreenhouseGases"] // EntityList
countries = {Entity["Country", "France"],
  Entity["Country", "Germany"],
  Entity["Country", "Italy"],
  Entity["Country", "Poland"],
  Entity["Country", "Spain"],
  Entity["Country", "Sweden"]}

emissionsFor[country_, gases_] := AssociationMap[
   country[EntityProperty["Country", "GreenhouseGasEmissions",
      {"GreenhouseGas" -> CanonicalName@#}]] &, gases] // 
  DeleteMissing

data = AssociationMap[emissionsFor[#, greenhouseGases] &, countries]

data // BarChart[#,
   ChartLabels -> {CanonicalName@Keys@#, None},
   ChartLegends -> CanonicalName@DeleteDuplicates@Keys@Values@#,
   PlotTheme -> "Detailed",
   FrameLabel -> {"Country", "Metric tons of carbon dioxide equivalent / Year"},
   ImageSize -> 500] &

enter image description here

POSTED BY: Rohit Namjoshi
Posted 4 years ago
POSTED BY: Rohit Namjoshi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard