Free
scales on faceted plot¶%useLatestDescriptors
%use dataframe
%use lets-plot
LetsPlot.getInfo()
Lets-Plot Kotlin API v.4.9.0. Frontend: Notebook with dynamically loaded JS. Lets-Plot JS v.4.5.1.
var mpg_df = DataFrame.readCSV("https://raw.githubusercontent.com/JetBrains/lets-plot-kotlin/master/docs/examples/data/mpg2.csv")
mpg_df.head()
DataFrame: rowsCount = 5, columnsCount = 9
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 |
---|---|---|---|---|---|---|---|---|
18.000000 | 8 | 307.000000 | 130 | 3504 | 12.000000 | 70 | US | chevrolet chevelle malibu |
15.000000 | 8 | 350.000000 | 165 | 3693 | 11.500000 | 70 | US | buick skylark 320 |
18.000000 | 8 | 318.000000 | 150 | 3436 | 11.000000 | 70 | US | plymouth satellite |
16.000000 | 8 | 304.000000 | 150 | 3433 | 12.000000 | 70 | US | amc rebel sst |
17.000000 | 8 | 302.000000 | 140 | 3449 | 10.500000 | 70 | US | ford torino |
val p = letsPlot(mpg_df.toMap()) {
x="engine horsepower"
y="engine displacement (cu. inches)"
} + geomPoint {color="origin of car"} + themeGrey()
p + ggsize(800, 350)
val fp = p + ggsize(800, 500)
facetGrid()
with fixed
scales (the default)¶Scales are constant across all panels.
fp + facetGrid(y="origin of car")
facetGrid()
with free
Y-scales¶fp + facetGrid(y="origin of car", scales="free_y")
facetWrap()
with fixed
scales (the default)¶Scales are constant across all panels.
fp + facetWrap(facets="number of cylinders", order=1)
facetWrap()
with free
scales along both axis¶fp + facetWrap(facets="number of cylinders", order=1, scales="free")