%useLatestDescriptors %use lets-plot %use dataframe LetsPlot.getInfo() var mpg = DataFrame.readCSV("https://raw.githubusercontent.com/JetBrains/lets-plot-kotlin/master/docs/examples/data/mpg.csv") mpg.head() val mpg100 = mpg.shuffle().take(100) letsPlot(mpg100.toMap()) + geomYDotplot {y = "hwy"} val PACIFIC_BLUE = "#118ed8" val plotBase = letsPlot(mpg100.toMap()) {x = "drv"; y = "hwy"} val plots = listOf( plotBase + geomViolin(fill = PACIFIC_BLUE, size = 0) + geomYDotplot(binWidth = 1.6, stackRatio=.5, fill = "white", color = PACIFIC_BLUE) + ggtitle("violin + ydotplot (method='dotdensity')"), plotBase + geomViolin(fill = PACIFIC_BLUE, size = 0) + geomYDotplot(binWidth = 1.6, stackRatio=.5, method = "histodot", fill = "white", color = PACIFIC_BLUE) + ggtitle("violin + ydotplot (method='histodot')"), ) gggrid(plots, 2, 450, 300) val plots1 = listOf( plotBase + geomYDotplot(binWidth = 1.5, stackDir = "left") + ggtitle("stackDir = \"left\""), plotBase + geomYDotplot(binWidth = 1.5, stackDir = "right") + ggtitle("stackDir = \"right\""), plotBase + geomYDotplot(binWidth = 1.5, stackDir = "center") + ggtitle("stackDir = \"center\""), plotBase + geomYDotplot(binWidth = 1.5, stackDir = "centerwhole") + ggtitle("stackDir = \"centerwhole\""), ) gggrid(plots1, 2, 450, 300) val plots2 = listOf( plotBase + geomYDotplot(binWidth = 1.5, stackRatio = 1) + ggtitle("stackRatio = 1"), plotBase + geomYDotplot(binWidth = 1.5, stackRatio = 0.5) + ggtitle("stackRatio = 0.5"), plotBase + geomYDotplot(binWidth = 1.5, stackRatio = 1.5) + ggtitle("stackRatio = 1.5"), ) gggrid(plots2, 2, 450, 300) val plots3 = listOf( plotBase + geomYDotplot(binWidth = 1.5, dotSize = 1) + ggtitle("dotSize = 1"), plotBase + geomYDotplot(binWidth = 1.5, dotSize = 0.5) + ggtitle("dotSize = 0.5"), plotBase + geomYDotplot(binWidth = 1.5, dotSize = 1.5) + ggtitle("dotSize = 1.5"), ) gggrid(plots3, 2, 450, 300) val plots4 = listOf( plotBase + geomYDotplot(binWidth = 1.5, method = "histodot") + ggtitle("Default"), plotBase + geomYDotplot(binWidth = 1.5, method = "histodot", center = 11) + ggtitle("center = 11"), ) gggrid(plots4, 2, 450, 300) val plots5 = listOf( plotBase + geomYDotplot(binWidth = 1.5, method = "histodot") + ggtitle("Default"), plotBase + geomYDotplot(binWidth = 1.5, method = "histodot", boundary = 12) + ggtitle("boundary = 12"), ) gggrid(plots5, 2, 450, 300) val plots6 = listOf( plotBase + geomYDotplot(method = "histodot") + ggtitle("Default (30)"), plotBase + geomYDotplot(method = "histodot", bins = 15) + ggtitle("bins = 15"), ) gggrid(plots6, 2, 450, 300) val plots7 = listOf( plotBase + geomYDotplot(binWidth = 1.6, stackRatio = .75, color = "white") { fill = asDiscrete("year") } + ggtitle("method = \"dotdensity\", stackGroups = false (default)"), plotBase + geomYDotplot(binWidth = 1.6, stackRatio = .75, color = "white", stackGroups = true) { fill = asDiscrete("year") } + ggtitle("method = \"dotdensity\", stackGroups = true"), plotBase + geomYDotplot(binWidth = 1.6, stackRatio = .75, color = "white", stackGroups = true, method = "histodot") { fill = asDiscrete("year") } + ggtitle("method = \"dotdensity\", stackGroups = true"), ) gggrid(plots7, 1, 800, 300, fit = true) letsPlot(mpg100.toMap()) {x = "drv"; y = "hwy"} + geomYDotplot(tooltips = layerTooltips() .title("Drivetrain: ^x") .line("stack center|^y") .line("Number of dots in stack|@..count..") .line("Dot diameter|@..binwidth..") ) val plotBase2 = plotBase + scaleColorBrewer(type="qual", palette="Set1") + scaleFillBrewer(type="qual", palette="Set1") + themeGrey() plotBase2 + geomYDotplot(binWidth = 1.5) { color = asDiscrete("drv") fill = asDiscrete("drv") } + facetGrid(x = "year") + ggtitle("facetGrid") letsPlot(mpg100.toMap()) + geomYDotplot(binWidth = 1.5, stackRatio = .3, dotSize = .8, color = "white") { x = "drv"; y = "hwy"; fill = "drv" } + coordFlip()