%useLatestDescriptors %use lets-plot %use dataframe LetsPlot.getInfo() letsPlot() + geomLabel(x=0, y=0, label="Lorem ipsum", size=14) + ggsize(500, 200) letsPlot() + geomLabel( x = 0, y = 0, label = "Lorem ipsum", size = 14, fill = "#edf8e9", color = "#238b45", fontface = "bold", labelPadding = 1.0, labelR = 0.5, labelSize = 2.0 ) + ggsize(500, 200) val families = listOf( "Arial", "Calibri", "Garamond", "Geneva", "Georgia", "Helvetica", "Lucida Grande", "Rockwell", "Times New Roman", "Verdana", "sans-serif", "serif", "monospace" ) letsPlot() + geomLabel(size = 10, labelPadding = 0, labelR = 0) { y = IntArray(families.size) { it }; label = families; family = families } val justifications = listOf(0, 0.5, 1) val angles = listOf(0, 45, 90) val values = justifications.flatMap { hjust -> justifications.flatMap { vjust -> angles.map { angle -> Triple(hjust, vjust, angle) } } } val data = mapOf( "hjust" to values.map { it.first }, "vjust" to values.map { it.second }, "angle" to values.map { it.third } ) letsPlot(data) { x = "hjust"; y = "vjust" } + geomPoint(size = 3) + geomLabel(label = "Text", size = 9) { hjust = "hjust"; vjust = "vjust"; angle = "angle" } + facetGrid(y = "angle", yFormat = "{d}°") + scaleXContinuous(breaks = listOf(0, 0.5, 1), expand = listOf(0.1)) + scaleYContinuous(breaks = listOf(0, 0.5, 1), expand = listOf(0.0, 0.5)) + themeClassic() + theme(panelBorder = elementRect(size = 1)) val mpg = DataFrame.readCSV("https://raw.githubusercontent.com/JetBrains/lets-plot-docs/master/data/mpg2.csv") mpg.head(3) val p = letsPlot(mpg.head(30).toMap()) { x = "vehicle weight (lbs.)" y = "miles per gallon" label = "vehicle name" } p + geomLabel() p + geomLabel(color = "white", fontface = "bold") { fill = asDiscrete("number of cylinders", order = 1) } + ggsize(800,400) // Initialize Lets-Plot GeoTools extension. %use lets-plot-gt(gt="[23,)") @file:DependsOn("org.geotools:gt-shapefile:[23,)") @file:DependsOn("org.geotools:gt-cql:[23,)") import org.geotools.data.shapefile.ShapefileDataStoreFactory import org.geotools.data.simple.SimpleFeatureCollection import java.net.URL import org.geotools.filter.text.cql2.CQL val factory = ShapefileDataStoreFactory() val worldFeatures : SimpleFeatureCollection = with("naturalearth_lowres") { val url = "https://raw.githubusercontent.com/JetBrains/lets-plot-kotlin/master/docs/examples/shp/${this}/${this}.shp" factory.createDataStore(URL(url)).featureSource.features } val europe = worldFeatures.subCollection(CQL.toFilter("continent = 'Europe'")) val cityFeatures : SimpleFeatureCollection = with("naturalearth_cities") { val url = "https://raw.githubusercontent.com/JetBrains/lets-plot-kotlin/master/docs/examples/shp/${this}/${this}.shp" factory.createDataStore(URL(url)).featureSource.features } val cities = cityFeatures.toSpatialDataset() letsPlot() + geomMap(map = europe.toSpatialDataset(), fill="#e5f5e0") + geomPoint(data = cities, color = "#224717", size = 3) + geomLabel(data = cities, hjust = 0, vjust = 1, color = "#224717") { label = "name" } + coordMap(xlim = -10.5 to 44.0, ylim = 36.0 to 60.5) + theme(axis="blank", panelGrid="blank")