Skip to content
Edition NigeriaGlobal
Country: Qatar

You are in the Qatar edition. Type your country to switch.

Set up your profile

You are learning in the Qatar edition, with examples in riyals and from Qatar.

Financial Data Lab · Lesson 3 of 8

Lab 3: plotting prices and returns

This lab draws the four charts most analysis needs, using matplotlib: a price line, two shares rebased to 100, a histogram of returns and a drawdown chart. It applies the honest-chart rules in code: labelled axes, stated sources and dates, log scales for long periods and no truncated bar axes.

Advanced10 min read5 steps

This lesson is complete in writing. A video for it is on its way.

What you will learn

  • By the end you can draw a labelled price chart from a pandas table with matplotlib and save it as an image file.
  • You can rebase two shares to 100 and compare them fairly on one chart.
  • You can choose between a normal and a log scale and explain the choice.
  • You can draw a histogram of returns and a drawdown chart, and apply the honest-chart rules to each.

Key terms in this lesson

Histogram
A chart that groups values into ranges, or bins, and shows how many fall in each. A histogram of returns shows their spread and tails.

Step 1 of 5

A first price chart, properly labelled

Opening this step…

Step 2 of 5

Comparing two shares: rebase to 100

This step opens when you finish the one above.

Step 3 of 5

Normal or log scale?

This step opens when you finish the one above.

Step 4 of 5

A histogram of returns and a drawdown chart

This step opens when you finish the one above.

Step 5 of 5

An honest-chart checklist in code

This step opens when you finish the one above.

Key takeaways

The key takeaways open when you finish every step.

Lesson quiz

6 questions. You need 85% to pass.

The quiz opens when you finish every step.

Read first

Stockertim Learn is education. It explains how investing works and never recommends buying or selling anything.

Up next

Financial data & analyticsLab 4: SQL on a price tableRead nowLab 4: SQL on a price tableFinancial data & analytics · Advanced · 15 minFinancial data & analyticsLab 5: cleaning corporate action…Read nowLab 5: cleaning corporate actions in codeFinancial data & analytics · Advanced · 15 minFinancial data & analyticsLab 6: a sentiment classifier on…Read nowLab 6: a sentiment classifier on sample headlinesFinancial data & analytics · Advanced · 15 minFinancial data & analyticsLab 7: watching a model overfitRead nowLab 7: watching a model overfitFinancial data & analytics · Advanced · 15 minFinancial data & analyticsCharts done right, and spotting …Read nowCharts done right, and spotting misleading chartsFinancial data & analytics · Intermediate · 15 minFinancial data & analyticsReading tables, charts and log s…Read nowReading tables, charts and log scalesFinancial data & analytics · Beginner · 15 minFinancial data & analyticsDistributions and fat tailsRead nowDistributions and fat tailsFinancial data & analytics · Intermediate · 15 minFinancial data & analyticsLab 2: computing returns in codeRead nowLab 2: computing returns in codeFinancial data & analytics · Advanced · 15 minFinancial data & analyticsFinancial data sourcesRead nowFinancial data sourcesFinancial data & analytics · Intermediate · 15 minFinancial data & analyticsLab 1: reading CSV files in Pyth…Read nowLab 1: reading CSV files in Python and SQLFinancial data & analytics · Advanced · 15 minFinancial data & analyticsFree against paid data, licensin…Read nowFree against paid data, licensing and terms of useFinancial data & analytics · Intermediate · 15 min
English