Skip to content

Commit bc5e299

Browse files
committed
added a scatter example
1 parent 1da2dfd commit bc5e299

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

README.md

+17
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,23 @@ produces
8383
0 1 2 3 4 5 6 7
8484
```
8585

86+
As another example to introduce a bit of customization:
87+
88+
```scala
89+
import org.sameersingh.scalaplot.Implicits._
90+
91+
val x = 0.0 until 10.0 by 0.01
92+
val rnd = new scala.util.Random(0)
93+
94+
output(PNG("docs/img/", "scatter"), xyChart(
95+
x -> Seq(Y(x, style = XYPlotStyle.Lines),
96+
Y(x.map(_ + rnd.nextDouble - 0.5), style = XYPlotStyle.Dots))))
97+
```
98+
99+
produces
100+
101+
![Example scatter](https://github.com/sameersingh/scalaplot/raw/master/docs/img/scatter.png)
102+
86103
### Output Formats
87104

88105
The library, of course, supports different output formats. Most of these also produce an accompanying Gnuplot source file, allowing archival and further customization if needed. The current list of formats are:

docs/img/scatter.png

5.16 KB
Loading

src/test/scala/org/sameersingh/scalaplot/ExampleXYTest.scala

+9-1
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,17 @@ class ExampleXYTest {
140140
}
141141

142142
@Test
143-
def testExamples(): Unit = {
143+
def testLineExample(): Unit = {
144144
import org.sameersingh.scalaplot.Implicits._
145145
val x = 0.0 until 2.0 * math.Pi by 0.1
146146
println(output(ASCII, xyChart(x ->(math.sin(_), math.cos(_)))))
147147
}
148+
149+
@Test
150+
def testScatterExample(): Unit = {
151+
import org.sameersingh.scalaplot.Implicits._
152+
val x = 0.0 until 10.0 by 0.01
153+
val rnd = new scala.util.Random(0)
154+
println(output(PNG("docs/img/", "scatter"), xyChart(x -> Seq(Y(x, style = XYPlotStyle.Lines), Y(x.map(_ + rnd.nextDouble - 0.5), style = XYPlotStyle.Dots)))))
155+
}
148156
}

0 commit comments

Comments
 (0)