6. Graphical Displays of Data

Table of Contents

MATLAB and R come with built-in functionality for producing graphical displays of data. For Python there is a library called matplotlib that provides MATLAB-like plotting capabilities. For C there is no easy option, but the unix program gnuplot is probably the best option, where you can pipe the output of a C program (or read a data file generated by a C program) into gnuplot and generate plots.

In each language, graphics are generated not using a pointy-clicky GUI but rather using a series of commands and functions (i.e. lines of code). This may seem burdensome at first, but in the long run it will make your life easier and you will have more power at your fingertips.

For example by saving the series of commands to generate a particular figure, it makes it much easier in the future when you decide (or are told) to modify the figure's appearance, and/or include new data, etc. All you have to do is modify the code and re-run it and your figure will be regenerated.

The other great advantage of generating figures using code is that you can bundle the code for data analysis together with the code for figure generation, and so other people (or yourself in the future) can easily regenerate figures after modifications to the data.


2 Python

3 R

4 C

For your language(s) of choice, have a look at the documentation above. In addition there are links to gallery pages showing a range of different plot styles, and the code that was used to generate the plots.

5 Exercises

The best way to learn the various graphical commands is to write code. Have a go at exercises 19 through 26.

Paul Gribble | fall 2014
This work is licensed under a Creative Commons Attribution 4.0 International License
Creative Commons License