Skip to content

Commit 2b9e104

Browse files
committedJun 22, 2015
Change plot to xyChart in README, closes #7
1 parent bc5e299 commit 2b9e104

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed
 

‎README.md

+29-29
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Currently, the library supports line and point (scatter) charts. Let's start wit
4444
import org.sameersingh.scalaplot.Implicits._
4545

4646
val x = 0.0 until 2.0 * math.Pi by 0.1
47-
output(PNG("docs/img/", "test"), plot(x ->(math.sin(_), math.cos(_))))
47+
output(PNG("docs/img/", "test"), xyChart(x ->(math.sin(_), math.cos(_))))
4848
```
4949

5050
which produces
@@ -54,7 +54,7 @@ which produces
5454
while
5555

5656
```scala
57-
output(ASCII, plot(x ->(math.sin(_), math.cos(_))))
57+
output(ASCII, xyChart(x ->(math.sin(_), math.cos(_))))
5858
```
5959

6060
produces
@@ -105,11 +105,11 @@ produces
105105
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:
106106

107107
```scala
108-
output(ASCII, plot(...)) // returns the string as above
109-
output(SVG, plot(...)) // returns the SVG text, which can be embedded in html or saved as a SVG file
110-
output(PDF(dir, name), plot(...)) // produces dir/name.gpl as the gnuplot source, and attempts dir/name.pdf
111-
output(PNG(dir, name), plot(...)) // produces dir/name.gpl as the gnuplot source, and attempts dir/name.png
112-
output(GUI, plot(...)) // opens a window with the plot, which can be modified/exported/resized/etc.
108+
output(ASCII, xyChart(...)) // returns the string as above
109+
output(SVG, xyChart(...)) // returns the SVG text, which can be embedded in html or saved as a SVG file
110+
output(PDF(dir, name), xyChart(...)) // produces dir/name.gpl as the gnuplot source, and attempts dir/name.pdf
111+
output(PNG(dir, name), xyChart(...)) // produces dir/name.gpl as the gnuplot source, and attempts dir/name.png
112+
output(GUI, xyChart(...)) // opens a window with the plot, which can be modified/exported/resized/etc.
113113
```
114114

115115
Note that scalaplot calls the `gnuplot` command to render the image in `dir/name.EXT`, but in case it fails, do the following:
@@ -121,29 +121,29 @@ $ gnuplot name.gpl
121121

122122
which will create `name.EXT`, where `EXT` is one of `PDF` or `PNG`.
123123

124-
### Plot
124+
### XYChart
125125

126-
The `plot` function is the main entry point for creating charts. The first argument of plot requires a `XYData` object, that we will describe in the next section. The rest of the arguments customize the aspects of the chart that are not data-specific.
126+
The `xyChart` function is the main entry point for creating charts. The first argument of plot requires a `XYData` object, that we will describe in the next section. The rest of the arguments customize the aspects of the chart that are not data-specific.
127127

128128
```scala
129129
val d: XYData = ...
130-
plot(d)
131-
plot(d, "Chart Title!")
132-
plot(d, x = Axis(label = "Age"), y = Axis(log = true))
130+
xyChart(d)
131+
xyChart(d, "Chart Title!")
132+
xyChart(d, x = Axis(label = "Age"), y = Axis(log = true))
133133
```
134134

135135
Here are the relevant definitions and default parameters that you can override:
136136

137137
```scala
138-
def plot(data: XYData, title: String = "",
139-
x: NumericAxis = new NumericAxis,
140-
y: NumericAxis = new NumericAxis,
141-
pointSize: Option[Double] = None,
142-
legendPosX: LegendPosX.Type = LegendPosX.Right,
143-
legendPosY: LegendPosY.Type = LegendPosY.Center,
144-
showLegend: Boolean = false,
145-
monochrome: Boolean = false,
146-
size: Option[(Double, Double)] = None): XYChart
138+
def xyChart(data: XYData, title: String = "",
139+
x: NumericAxis = new NumericAxis,
140+
y: NumericAxis = new NumericAxis,
141+
pointSize: Option[Double] = None,
142+
legendPosX: LegendPosX.Type = LegendPosX.Right,
143+
legendPosY: LegendPosY.Type = LegendPosY.Center,
144+
showLegend: Boolean = false,
145+
monochrome: Boolean = false,
146+
size: Option[(Double, Double)] = None): XYChart
147147
def Axis(label: String = "",
148148
backward: Boolean = false,
149149
log: Boolean = false,
@@ -163,10 +163,10 @@ val y1 = (1 until 100).map(j => math.pow(j, 1))
163163
val y2 = (1 until 100).map(j => math.pow(j, 2))
164164
val y3 = (1 until 100).map(j => math.pow(j, 3))
165165

166-
plot(x ->(y1, y2, y3))
167-
plot(x ->(math.sin(_), math.cos(_))) // inline definition
168-
plot(x -> Seq(Y(y1, "1"), Y(y2, "2"), Y(y3, "3"))) // with labels and other possible customizations
169-
plot(x -> Seq(Yf(math.sin, "sin"), Yf(math.cos, color = Color.Blue), Yf(math.tan, lw = 3.0))) // Yf for functions
166+
xyChart(x ->(y1, y2, y3))
167+
xyChart(x ->(math.sin(_), math.cos(_))) // inline definition
168+
xyChart(x -> Seq(Y(y1, "1"), Y(y2, "2"), Y(y3, "3"))) // with labels and other possible customizations
169+
xyChart(x -> Seq(Yf(math.sin, "sin"), Yf(math.cos, color = Color.Blue), Yf(math.tan, lw = 3.0))) // Yf for functions
170170
```
171171

172172
where each series can be fully customized using the following:
@@ -195,13 +195,13 @@ def Yf(f: Double => Double,
195195
If you have sequences of `(x,y)` pairs as your data, or if you want to use different `x` for each series:
196196

197197
```scala
198-
plot(List(x -> Y(y1), x -> Y(y2)))
199-
plot(List(x -> Y(y1, "1"), x -> Y(y2, color = Color.Blue)))
198+
xyChart(List(x -> Y(y1), x -> Y(y2)))
199+
xyChart(List(x -> Y(y1, "1"), x -> Y(y2, color = Color.Blue)))
200200

201201
val xy1 = x zip y1
202202
val xy2 = x zip y2
203-
plot(List(XY(xy1), XY(xy2)))
204-
plot(List(XY(xy1, "1"), XY(xy2, "2")))
203+
xyChart(List(XY(xy1), XY(xy2)))
204+
xyChart(List(XY(xy1, "1"), XY(xy2, "2")))
205205
```
206206

207207
where the customization is similar to above:

0 commit comments

Comments
 (0)