CS112: Lab 2 :: More MATLAB ::: more plotting

Let's work with some Facebook statistics* from May 2006 to May 2007 to create some more involved plots. Back in 2007, Facebook had 50 million users. In 2011, Facebook reached 750 million users; in 2018, 2.32 billion users.

Connect to the cs112 download folder using Cyberduck and grab a copy of facebook.m as a starting place to create these plots. This MATLAB script merely contains the data shown below and the corresponding date information. As you create your versions of the plots below, make use of MATLAB's help to guide you.

Date 05/06 06/0607/0608/0609/0610/06 11/0612/0601/0702/07 03/0704/0705/07
unique visitors 14069 13752 14365 14782 13341 1510816695 19105 18961 16737 20896 23042 26649
pages viewed 6530 60936108 646371619437 90399064 10360 10779 12179 1499715841
minutes per visitor 138 127130 134175187 172 150 170 200 180 196 186

Exercise 1: Create this plot

Plotting Pages Viewed against Date

This is basically the default MATLAB single line plot. Your plot should have:

  • line plot
  • labeled axes
  • title
  • legend
Hint: Use MATLAB's help to learn how to change the placement of the legend in your plot
Exercise 2: Create this plot

Plotting Unique Visitors against Date

This is a more colorful, easy-to-read line plot with a labeled point. You can choose your own colors/linestyles/line markers/point to mark/fonts/etc.

Your plot should have:

  • non-default axes labels
  • non-default title
  • a labeled point
  • non-default tick marks on both axes
Hints:
  • Bring up MATLAB's help page on "Line Specification"
  • Some useful MATLAB commands/properties to explore there: LineWidth, MarkerEdgeColor, MarkerFaceColor, MarkerSize, XTick, XTickLabel, YTick, YTickLabel, and text.
  • a short, local, reference on plot Properties
  • xlabel, ylabel and title also use properties (use MATLAB's help to explore)
  • Background color can be set using gca
Exercise 3: Create this plot

Multiple Lines in One Plot

As above, you have complete artistic freedom in choosing your colors/fonts/styles. Your plot should have:

  • 2 lines, each with a distinct look
  • a legend
  • non-default labels, tickmarks and title
*Facebook statistics from comscore.com.