Week 5: Matplotlib#

5.1 - Line Plots - [Notebook] - [Video]#

  • Using plt.plot

    • Plotting a line between two points

    • Plotting line between multiple points

    • Plotting a function

    • Plotting two lines in the same figure

  • Plot Aesthetics

    • Changing line colour

    • Changing line width

    • Changing line style

    • Changing marker style

  • Axis Formatting

    • Setting limits

    • Changing ticks

    • Adding grids

  • Labels

    • Adding a title

    • Labeling axes

  • Error Bars

  • Asymptotes and Annotations

  • Log Plots

    • Making log-log plots

    • Making semi-log plots

  • Figure Object

    • Creating a figure

    • Adding axes to figure

    • Adjusted functions

    • Saving an image

5.2 - Multiple and Alternative Plots - [Notebook] - [Video]#

  • Subplots

    • Making sub-plots using plt.subplot()

    • Plots in Plots

    • Making sub-plots using fig.add_subplot()

    • Making sub-plots using plt.subplots()

  • Histograms

  • Scatter Plot

  • Bar Chart

  • Pie Chart

5.3 - 3D Plots and Animations - [Notebook] - [Video]#

  • 3D Line Plot

  • Heatmap

  • Surface Plot

  • Interactive Backend

  • Animation

    • Making an initialisation function

    • Making an animation function

    • Animating a plot

    • Saving an animation

5.4 Cheatsheet#

5.5 Tutorial#

  1. Noise in qubits

  2. Particle in a Box

  3. Normal Distribution

  4. Monte Carlo \(\pi\) Estimation

  5. Ball Animation

5.6 Exercises#

  1. Settlers of Histogram

  2. Normal Distribution

  3. Particle in a Box

  4. Plotting a Sphere

  5. Snake Animation