Skip to content

Commit

Permalink
Make mdoc compile
Browse files Browse the repository at this point in the history
  • Loading branch information
pityka committed Feb 14, 2023
1 parent 7c5ba56 commit 7199abe
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 55 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Renders to

See the documentation website at [https://pityka.github.io/nspl/](https://pityka.github.io/nspl/) .

This library is built for Scala 2.13 and Scala 3.1.
This library is built for Scala 2.13 and Scala 3.2.

Maven coordinates:

Expand Down
2 changes: 1 addition & 1 deletion docs/content/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ weight: 1

# Scala plotting library
nspl is a fast and expressive plotting library for the Scala programming language.
nspl can create various plots (scatter, line, bar, box etc) and complex figures.
nspl can create various scientific plots (scatter, line, bar, box etc) and complex figures.

## Platforms and output formats
The library supports Scala on the JVM and Scala.js in the browser.
Expand Down
36 changes: 21 additions & 15 deletions docs/content/docs/datarenderers/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ An example with triples where the third column (the third element in the triple)


val plot4 = xyplot(data -> point())(
par(xlab="x axis label",
ylab="y axis label")
par
.xlab("x axis label")
.ylab("y axis label")
)

renderToByteArray(plot4.build, width=2000)
Expand All @@ -52,9 +53,10 @@ import org.nspl._
import org.nspl.awtrenderer._

val plot5 = xyplot(data -> line())(
par(xlab="x axis label",
ylab="y axis label")
)
par
.xlab("x axis label")
.ylab("y axis label"))


renderToByteArray(plot5.build, width=2000)
```
Expand All @@ -69,8 +71,9 @@ import org.nspl._
import org.nspl.awtrenderer._

val plot6 = xyplot(data -> lineSegment(color = Color.black))(
par(xlab="x axis label",
ylab="y axis label")
par
.xlab("x axis label")
.ylab("y axis label")
)

renderToByteArray(plot6.build, width=2000)
Expand All @@ -89,10 +92,11 @@ import org.nspl._
import org.nspl.awtrenderer._

val plot7 = xyplot(data.take(2) -> polynom(() => line()))(
par(xlab="x axis label",
ylab="y axis label",
xlim = Some(0d -> 1d),
ylim = Some(0d -> 1d))
par
.xlab("x axis label")
.ylab("y axis label")
.xlim(Some(0d -> 1d))
.ylim(Some(0d -> 1d))
)

renderToByteArray(plot7.build, width=2000)
Expand All @@ -114,10 +118,12 @@ val plot8 = xyplot(
width = 0.5,
fill = Color.gray2)
)(
par(xlab="x axis label",
ylab="y axis label",
xlim = Some(0d -> 3d))
)
par
.xlab("x axis label")
.ylab("y axis label")
.xlim(Some(0d -> 3d))
)


renderToByteArray(plot8.build, width=2000)
```
Expand Down
47 changes: 25 additions & 22 deletions docs/content/docs/gallery/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,14 @@ val data2 = data.addCol(spec, "spec", InnerJoin)
val fig0 = xyplot(
data2.col("Sepal.Length", "Sepal.Width", "spec")
)(
par(extraLegend = spec2Num.toSeq.map(x =>
par.extraLegend(spec2Num.toSeq.map(x =>
x._1 -> PointLegend(
shape = Shape.rectangle(0, 0, 1, 1),
color = DiscreteColors(spec2Num.size)(x._2)
)
),
xlab = "Sepal.Length",
ylab = "Sepal.Width",
main = "Iris data")
)).xlab("Sepal.Length")
.ylab("Sepal.Width")
.main("Iris data")
)

val fig1 = xyplot(
Expand All @@ -93,27 +92,30 @@ val data2 = data.addCol(spec, "spec", InnerJoin)
.toSeq
)
)(
par(extraLegend = spec2Num.toSeq.map(x =>
x._1 -> PointLegend(
shape = Shape.rectangle(0, 0, 1, 1),
color = DiscreteColors(spec2Num.size)(x._2)
par
.extraLegend(spec2Num.toSeq.map(x =>
x._1 -> PointLegend(
shape = Shape.rectangle(0, 0, 1, 1),
color = DiscreteColors(spec2Num.size)(x._2)
)
)
)
),
xlab = "PC1",
ylab = "PC2",
main = "PC1 vs PC2")
.xlab("PC1")
.ylab("PC2")
.main("PC1 vs PC2")
)



val scree = xyplot(
indexed(eval.firstCol("x").toVec.toSeq.sorted.reverse) -> line()
)(
par(xAxisMargin = 0,
xlab = "Order",
ylab = "Eval",
main = "Scree"
))
par
.xAxisMargin(0)
.xlab("Order")
.ylab("Eval")
.main("Scree")
)

renderToByteArray(
group(fig0,fig1,scree,TableLayout(2)).build,
Expand All @@ -127,10 +129,11 @@ val data2 = data.addCol(spec, "spec", InnerJoin)
val hist1 = xyplot(
HistogramData(rotated.firstCol("PC1").toVec.toSeq, 10) -> bar()
)(
par(xlab = "PC1",
ylab = "freq.",
main = "Loading distribution",
ylim = Some(0d, Double.NaN))
par
.xlab("PC1")
.ylab("freq.")
.main("Loading distribution")
.ylim(Some(0d -> Double.NaN))
)

renderToByteArray(hist1.build,width=2000)
Expand Down
2 changes: 0 additions & 2 deletions docs/content/docs/layouts/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ Or the same with `sequence()`:
```scala mdoc:bytes:assets/layout2.png
import org.nspl._
import org.nspl.awtrenderer._
import org.nspl.data.DataMatrix
import scala.util.Random.nextDouble

val sequencedPlot = sequence(List(plot1,plot2),TableLayout(2))

Expand Down
24 changes: 11 additions & 13 deletions docs/content/docs/usage/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,7 @@ The most important method in nspl's API is the `xyplot()()` method, a factory fo
Its signature is roughly:
```scala
def xyplot[F: FC](data: (DataSource, List[DataRenderer], LegendConfig)*)(
xlog: Boolean = false,
ylog: Boolean = false,
main: String = "",
xlab: String = "",
ylab: String = "",
.. many other global plot parameters ..)
parameters: Parameters)
```

In the first parameter list of `xyplot` we give one or more data sources each with zero or more `DataRenderer`.
Expand All @@ -62,6 +57,8 @@ For the full list of data renderers see the methods in the [Renderers trait]({{<

The third element of the triple controls whether the data source is included in the legend or not.

Finally, `Parameters` is an immutable holder of commont plot settings. There is a default instance of it named `par` at `org.nspl.par` . The class defines specialized copy methods following a builder like pattern e.g. one can write `par.withXLab("some label")`.

In the below example we have a single data source, each row is plotted as a series of consecutive line segments and also as a point. Finally, the data source is included in the legend.
```scala mdoc:bytes:assets/usage1.png
import org.nspl._
Expand All @@ -76,8 +73,9 @@ val someData =
)

val plot = xyplot((someData , List(point(),line()), InLegend("series 1")))(
par(xlab="x axis label",
ylab="y axis label")
par
.withXLab("x axis label")
.withYLab("y axis label")
)

renderToByteArray(plot, width=2000)
Expand All @@ -99,10 +97,11 @@ val sparseMatrix =
(2d, 2d, 1d),
)

val plot2 = rasterplot(sparseMatrix)(par(
xlab="x axis label",
ylab="y axis label"
))
val plot2 = rasterplot(sparseMatrix)(
par
.withXLab("x axis label")
.withYLab("y axis label")
)

renderToByteArray(plot2.build, width=2000)
```
Expand Down Expand Up @@ -132,7 +131,6 @@ There is also a factory method which does all these in one call:
```scala mdoc:bytes:assets/usage_box.png
import org.nspl._
import org.nspl.awtrenderer._
import org.nspl.data.DataMatrix
import scala.util.Random.nextDouble

val randomData1 = 0 until 10 map (_ => nextDouble())
Expand Down
2 changes: 1 addition & 1 deletion docs/content/imports/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import org.nspl.awtrenderer._

If you don't want to pollute the namespace then you can import only the `FontConfiguration` implicit instance, and prefix every call with its package e.g.

```scala mdoc
```scala
import org.nspl
import org.nspl.awtrenderer.{defaultGlyphMeasurer, defaultAWTFont}
```

0 comments on commit 7199abe

Please sign in to comment.