First page Back Continue Last page Overview Image

Using Twin Axes, Part 1

We multiplied the area column by 1000 to get a proper output. Instead of this, we could have used twin axes. We will demonstrate this in the following example. We will recreate the city_frame DataFrame to get the original area column:

import pandas as pd

import matplotlib.pyplot as plt

cities = {"name": ["London", "Berlin", "Madrid", "Rome",

"Paris", "Vienna"],

"population": [8615246, 3562166, 3165235, 2874038,

2273305, 1805681],

"area" : [1572, 891.85, 605.77, 1285, 105.4, 414.6]}

city_frame = pd.DataFrame(cities,

columns=["population", "area"],

index=cities["name"])

print(city_frame)