forked from plotly/documentation
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request plotly#446 from ASIDataScience/scala/v0.2-changes
Documentation for Scala client v0.2.0
- Loading branch information
Showing
15 changed files
with
294 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
name: Mixed 2D and 3D subplots | ||
plot_url: https://plot.ly/~pbugnion/554 | ||
language: scala | ||
suite: subplots | ||
order: 2 | ||
sitemap: false | ||
arrangement: horizontal | ||
--- | ||
|
||
import co.theasi.plotly | ||
import util.Random | ||
|
||
// Left-hand side: Gaussian distributed random variates | ||
val randomXs = (0 to 100).map { i => Random.nextGaussian } | ||
val randomYs = (0 to 100).map { i => Random.nextGaussian } | ||
|
||
val leftPlot = Plot() | ||
.withScatter(randomXs, randomYs, ScatterOptions().mode(ScatterMode.Marker)) | ||
|
||
// Gaussian PDF | ||
def gaussian2D(x: Double, y: Double) = Math.exp(-x*x - y*y) | ||
|
||
val xs = (-4.0 to 4.0 by 0.1).toVector | ||
val ys = (-4.0 to 4.0 by 0.1).toVector | ||
val zs = xs.map { x => ys.map { y => gaussian2D(x, y) } } | ||
|
||
val rightPlot = ThreeDPlot().withSurface(xs, ys, zs) | ||
|
||
// Figure with two subplots in a row | ||
val figure = RowFigure(2) | ||
.plot(0) { leftPlot } | ||
.plot(1) { rightPlot } | ||
|
||
draw(figure, "mixed-subplots", writer.FileOptions(overwrite=true)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
15 changes: 15 additions & 0 deletions
15
_posts/scala/surface-subplots/2016-06-19-3d_surface_subplots_index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
title: 3D Subplots | Examples | Plotly | ||
name: 3D Subplots | ||
permalink: scala/3d-subplots/ | ||
description: How to create subplots with 3D graphs in Scala | ||
layout: base | ||
thumbnail: thumbnail/3d-subplots.jpg | ||
language: scala | ||
page_type: example_index | ||
has_thumbnail: true | ||
display_as: 3d_charts | ||
order: 5 | ||
--- | ||
{% assign examples = site.posts | where:"language","scala" | where:"suite","3d-subplots" | sort: "order" %} | ||
{% include auto_examples.html examples=examples %} |
46 changes: 46 additions & 0 deletions
46
_posts/scala/surface-subplots/2016-06-19-surface-subplots.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--- | ||
name: 3D surface subplots | ||
plot_url: https://plot.ly/~pbugnion/546 | ||
language: scala | ||
suite: 3d-subplots | ||
order: 2 | ||
sitemap: false | ||
arrangement: horizontal | ||
--- | ||
|
||
val xs = (-3.0 to 3.0 by 0.2).toVector | ||
val ys = (-3.0 to 3.0 by 0.2).toVector | ||
|
||
// 2-dimensional quantum harmonic oscillator energy levels | ||
def gaussian2D(x: Double, y: Double): Double = Math.exp(-x*x - y*y) | ||
val z00 = xs.map { x => ys.map { y => gaussian2D(x, y) } } | ||
val z01 = xs.map { x => ys.map { y => y*gaussian2D(x, y) } } | ||
val z11 = xs.map { x => ys.map { y => x*y*gaussian2D(x, y) } } | ||
val z20 = xs.map { x => ys.map { y => (1-2*x*x)*gaussian2D(x, y) } } | ||
|
||
val options = SurfaceOptions().noScale | ||
|
||
val figure = GridFigure(2, 2) // four plots split over two rows | ||
.title("Eigenfunctions of the 2D quantum harmonic oscillator") | ||
.plot(0, 0) { // top left | ||
ThreeDPlot() | ||
.withSurface(xs, ys, z00, options) | ||
.zAxisOptions(AxisOptions().title("psi_00")) | ||
} | ||
.plot(0, 1) { // top right | ||
ThreeDPlot() | ||
.withSurface(xs, ys, z01, options) | ||
.zAxisOptions(AxisOptions().title("psi_01")) | ||
} | ||
.plot(1, 0) { // bottom left | ||
ThreeDPlot() | ||
.withSurface(xs, ys, z11, options) | ||
.zAxisOptions(AxisOptions().title("psi_11")) | ||
} | ||
.plot(1, 1) { // bottom right | ||
ThreeDPlot() | ||
.withSurface(xs, ys, z20, options) | ||
.zAxisOptions(AxisOptions().title("psi_20")) | ||
} | ||
|
||
draw(figure, "qho-eigenfunctions") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
name: 3D surface plot | ||
plot_url: https://plot.ly/~pbugnion/518 | ||
language: scala | ||
suite: surface | ||
order: 1 | ||
sitemap: false | ||
arrangement: horizontal | ||
--- | ||
|
||
val xs = (-3.0 to 3.0 by 0.1).toVector | ||
val ys = (-3.0 to 3.0 by 0.1).toVector | ||
|
||
def gaussian2D(x: Double, y: Double) = Math.exp(-x*x - y*y) | ||
val zs = xs.map { x => ys.map { y => gaussian2D(x, y) } } | ||
|
||
val p = ThreeDPlot().withSurface(xs, ys, zs) | ||
|
||
draw(p, "gaussian-surfaces") |
15 changes: 15 additions & 0 deletions
15
_posts/scala/surface/2016-06-19-3d_surface_plots_index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
title: 3D Surface plots | Examples | Plotly | ||
name: 3D Surface plots | ||
permalink: scala/3d-surface-plots/ | ||
description: How to create surface plots in Plotly with Scala. | ||
layout: user-guide | ||
thumbnail: thumbnail/3d-surface.jpg | ||
language: scala | ||
page_type: example_index | ||
has_thumbnail: true | ||
display_as: 3d_charts | ||
order: 4 | ||
--- | ||
{% assign examples = site.posts | where:"language","scala" | where:"suite","surface" | sort: "order" %} | ||
{% include auto_examples.html examples=examples %} |
Oops, something went wrong.