Say Cheese!

The following was written by Isabel Skidmore and was originally published on the Wolfram Blog. The original post can be viewed here.

We think about it, talk about it, dream about it and sometimes even argue about it.

What is it?

Food!

March is National Nutrition Month, and I want to share with you how we can celebrate it with the Wolfram Language. We’ll explore ways to analyze and visualize the incredible amount of food and nutrition data available to you in Wolfram|Alpha.

Go Bananas with Images

Did you know that Wolfram|Alpha has nutritional data on 150 types of fruit?

Using the ImageCollage function, you can quickly create a colorful snapshot of the many fruits in the Wolfram Knowledgebase.

First, find all instances of FoodType that are within the FoodTypeGroup “Fruits”:

fruitFoodTypes code

Next, get the image for each of these, and use DeleteMissing to remove any missing values from the list:

fruitImages code

Finally, use ImageCollage to create a vibrant collage of the fruit images:

ImageCollage with various photo of fruit in a collage

To produce the same type of image collage for different types of pasta, just replace each use of “fruit” or “Fruits” from the earlier code with “pasta” or “Pastas”:

pastaFoodtypes code
pastaImages code
ImageCollage with various photo of pasta in a collage

Try these other food groups to create a whole gallery of Wolfram|Alpha image collages to celebrate National Nutrition Month:

  • “Berries”
  • “Breads”
  • “Cheeses”
  • “Legumes”

A Cloud of Carbs

These days, many people have questions about the “carbs” in their food. The Wolfram Language makes answering those questions informative and fun. A word cloud is the perfect way to quickly illustrate the relative carbohydrate content in different grains.

First, find all instances of FoodType that are within the BasicFoodGroup “Grains”:

grains code

Next, retrieve the relative carbohydrate content and names for all the food types included in the “Grains” EntityClass:

grainNames code

Finally, use WordCloud to create a colorful and informative graphic. The larger the word, the greater the number of relative carbs!

Word cloud of grain names with color coding and size indicating carb levels

Try these other relative comparisons to create vibrant and educational word clouds:

  • “fruits” and RelativeVitaminCContent
  • “dairy” and RelativeCalciumContent

Navigating a World of Flavors

Many of us enjoy trying new foods and flavors from around the world. Wolfram|Alpha has nutritional data about the foods that sometimes travel many miles before arriving on our plates.

CompassPlot is a quick and easy function in the Wolfram Language for learning about the macronutrient content of exotic and delicious foods like these fruits:

CompassPlot graph for plantain
CompassPlot graph for avocado

You can use CompassPlot to check out “Fig”, “Lychee”, “Banana”, “Jackfruit”, “Coconut”, “Tamarind” and “Durian” — the fruit famous (or infamous) for its pungent smell:

CompassPlot graph for durian

CompassPlot is perfect for exploring the nutritional makeup of your favorite pasta. For example, let’s take a look at “Orecchiette” pasta:

CompassPlot graph for orecchiette

Did you know that “orecchiette” translates to “little ear”? This picture shows why that is:

Image of orecchiette pasta, which looks like small, shell-shaped ears

You can also use the Wolfram Language to analyze the protein and fat content of your favorite international meats and cheeses:

CompassPlot graph for paneer
CompassPlot graph for chorizo

See how these compare with “Ricotta”, “Bratwurst” and “Prosciutto”.

Before we leave CompassPlot, let’s explore Native American cuisine by using the Wolfram Language to visualize the macronutrient profile of blue cornmeal:

CompassPlot graph of blue cornmeal

Even better, Wolfram|Alpha can give you an image of piki, the traditional bread of the Hopi made with blue cornmeal:

Nutritional and Multidimensional

Just as foods are multidimensional — sweet, sour, salty, bitter and/or spicy — so is food data in Wolfram|Alpha.

Use the following Wolfram Language code to create a 3D graphic of the relative carbohydrate, protein and fiber content of a wide variety of crackers. Then, in a Wolfram Notebook, hover over the data points to find your favorite ones in the plot:

Code on EntityType for crackers
Additional values such as carbohydrate content added to the crackers code
Graphics3D code showing various nutrition values plotted for crackers

Eat Healthy and Be Happy

I hope you enjoy celebrating food and National Nutrition Month via the Wolfram Language as much as I do, and bon appétit!

--

--

Tech-Based Teaching Editor
Tech-Based Teaching: Computational Thinking in the Classroom

Tech-Based Teaching is all about computational thinking, edtech, and the ways that tech enriches learning. Want to contribute? Reach out to edutech@wolfram.com.