Skip to content

Latest commit

 

History

History
87 lines (64 loc) · 1.98 KB

File metadata and controls

87 lines (64 loc) · 1.98 KB

Class 16: matplotlib 2 - graphing

Introduction

This is part 2 of the matplotlib introduction. The material in classes 15 and 16 is covered in a video:

http://youtu.be/zwzR0z0_Gn0

Matplotlib continued

reload wander
dir, m = wander.wander_list('2011-10-11.gga.dat.bz2')

cla()
plot dir

Errr… dir runs -180 to +180. Let’s make that 0..360:

dir360 = [ d if d>0 else d+360 for d in dir ]

Didn’t get that last line? I’ll explain it more in a video.

Fancier plotting - histograms and subplots

It would be nice to be able to make a figure with multiple plots and maybe have a histogram. Let’s try making a histogram first.

cla()
hist(m)
hist(m, bins=30)
hist(m, bins=100)

Which is a reminder that you are warned that histograms are not a stable concept. How they look depends heavily on the number of bins.

Warning: matplotlib is designed to follow how matlab does plotting. That means that subplots start counting from 1, not 0. Bummer.

cla()
subplot (411)
plot(dir360)
plot(x)
subplot (412)
plot(y)
subplot (413)
plot(m)
subplot (414)
hist(m, bins=200)

Working with arrays

We can start building up capabilities

zeros(30)
ones(10)
concatonate( (zeros(100), ones(100), zeros(100) ) )

TODO Questions

  • What is “interactive mode” for matplotlib?
  • Switching figures
  • Splitting 15 into 15 & 16