Free
scales on a faceted plot¶import pandas as pd
from lets_plot import *
LetsPlot.setup_html()
data = pd.read_csv('https://raw.githubusercontent.com/JetBrains/lets-plot-docs/master/data/mpg2.csv')
data.head(3)
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 |
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)
fp = p + ggsize(800, 500)
facet_grid()
with fixed
scales (the default)¶Scales are constant across all panels.
fp + facet_grid(y='origin of car')
facet_grid()
with free
Y-scales¶fp + facet_grid(y='origin of car', scales='free_y')
facet_wrap()
with fixed
scales (the default)¶Scales are constant across all panels.
fp + facet_wrap(facets="number of cylinders", order=1)
facet_wrap()
with free
scales along both axis¶fp + facet_wrap(facets="number of cylinders", order=1, scales='free')