Visualize Distribution of Channel Data with a Box Plot

This example shows how to draw a box plot from data in your ThingSpeak™ channel and visualize the distribution of the data.

Read Data from ThingSpeak Car-Counter Channel

ThingSpeak channel 38629 contains data obtained with a Raspberry Pi™ and a webcam that counts cars on a busy highway. The car-counting algorithm runs on the Raspberry Pi and it sends the car count every 15 seconds to ThingSpeak. Fields 1 and 2 contain eastbound and westbound traffic data, respectively.

data = thingSpeakRead(38629,'NumDays',1,'Fields',[1,2],'outputFormat','table');

Draw a Box Plot

Visualize the distribution of eastbound and westbound traffic data with the boxplot function that shows minimum, maximum, median, first quartile, and third quartile.

boxplot([data.DensityOfEastboundCars data.DensityOfWestboundCars],'Notch','on', ...
    'Labels',{'All Eastbound Cars','All Westbound Cars'});
ylabel('Density of cars every 15 seconds');
title('Boxplot of Eastbound and Westbound traffic in the last 24 hours');

The box plot shows the median, minimum and maximum number of cars fo the eastbound and westbound traffic. The whiskers default to cover 99.3 percent of the data. The bottom and top of the box indicate the first and third quartile; the distribution of westbound traffic is notably smaller.

See Also

Functions