Free scales on a faceted plot

In [1]:
import pandas as pd

from lets_plot import *
LetsPlot.setup_html()
In [2]:
data = pd.read_csv('https://raw.githubusercontent.com/JetBrains/lets-plot-docs/master/data/mpg2.csv')
data.head(3)
Out[2]:
miles per gallon number of cylinders engine displacement (cu. inches) engine horsepower vehicle weight (lbs.) time to accelerate (sec.) model year origin of car vehicle name
0 18.0 8 307.0 130 3504 12.0 70 US chevrolet chevelle malibu
1 15.0 8 350.0 165 3693 11.5 70 US buick skylark 320
2 18.0 8 318.0 150 3436 11.0 70 US plymouth satellite
In [3]:
p = (ggplot(data, aes(x="engine horsepower", y="engine displacement (cu. inches)")) + 
     geom_point(aes(color="origin of car")) + theme_grey())
p + ggsize(800, 350)
Out[3]:

Faceted plot

In [4]:
fp = p + ggsize(800, 500)

facet_grid() with fixed scales (the default)

Scales are constant across all panels.

In [5]:
fp + facet_grid(y='origin of car')
Out[5]:

facet_grid() with free Y-scales

In [6]:
fp + facet_grid(y='origin of car', scales='free_y')
Out[6]:

facet_wrap() with fixed scales (the default)

Scales are constant across all panels.

In [7]:
fp + facet_wrap(facets="number of cylinders", order=1)
Out[7]:

facet_wrap() with free scales along both axis

In [8]:
fp + facet_wrap(facets="number of cylinders", order=1, scales='free')
Out[8]: