Add a bar series to this plot.
Add a box plot to this plot.
[use case] Add a scatter plot to this plot.
Add a scatter plot to this plot.
The 'xs' series. This can be an iterable of any type T, provided an instance of the typeclass 'Writable[T]' exists.
The 'ys' series.
(optional) Options controlling the plot style.
Copy of this plot with the scatter series added.
val xs = Vector(1.0, 2.0, 3.0) val ys1 = xs.map { _ * 2.0 } val ys2 = xs.map { _ * (-2.0) } val p = CartesianPlot() .withScatter(xs, ys1) .withScatter(xs, ys2, ScatterOptions().name("series-2"))
Set the x-axis options for this plot.
Set the y-axis options for this plot.
Plot with Cartesian axes
Example usage
This class draws a sub-plot on Cartesian axes. This can be used to draw bar charts, scatter plots, box plots, contour plots etc.: anything that has an x- and a y-axis.
CartesianPlot
instances can be sent directly to Plotly:They can also be embedded in Figure instances for more complex plot layouts:
Multiple lines
CartesianPlot
instances support multiple series:The immutable builder pattern
When you call the
.withScatter
method on aCartesianPlot
object, it returns a new plot with the new data series added.CartesianPlot
instances are immutable. Thus, the following will not work:Do this instead:
Or, better yet, use chaining to avoid creating temporary variables:
All methods in this class work in the same way: they return a new instance of
CartesianPlot
. This pattern is called the immutable builder pattern: it is a variant of the common builder pattern adapted for immutable objects.