Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/facultyai/scala-plotly-client
Visualise your data from Scala using Plotly
https://github.com/facultyai/scala-plotly-client
data-science graph plot plotly scala visualisation
Last synced: about 6 hours ago
JSON representation
Visualise your data from Scala using Plotly
- Host: GitHub
- URL: https://github.com/facultyai/scala-plotly-client
- Owner: facultyai
- License: mit
- Created: 2016-03-04T14:50:21.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-08-15T16:35:28.000Z (about 4 years ago)
- Last Synced: 2024-03-25T20:20:49.859Z (8 months ago)
- Topics: data-science, graph, plot, plotly, scala, visualisation
- Language: Scala
- Homepage: https://facultyai.github.io/scala-plotly-client/
- Size: 751 KB
- Stars: 40
- Watchers: 12
- Forks: 11
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.org/ASIDataScience/scala-plotly-client.svg)](https://travis-ci.org/ASIDataScience/scala-plotly-client)
# Plotly client
## Installation
To add the plotly client to your code, add the following lines to your `build.sbt`:
```scala
libraryDependencies += "co.theasi" %% "plotly" % "0.2.0"
```To install the bleeding edge version, add this instead:
```scala
resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots"libraryDependencies += "co.theasi" %% "plotly" % "0.2.1-SNAPSHOT"
```## Documentation
- Tutorials will be included as part of the [Plotly documentation](https://plot.ly/api/) when the interface stabilises.
- [API documentation](http://asidatascience.github.io/scala-plotly-client/latest/api/#co.theasi.plotly.package).
## Authentication
To create a graph on Plotly, start by opening an account with the web UI. Then create an API key by clicking on your username in the top right hand corner of the screen and selecting *SETTINGS > API KEYS*. Create the file `~/.plotly/.credentials` in your home directory. The file should look like:
```json
{
"username": "pbugnion",
"api_key": "l233fgfdsjk"
}
```Note that if you have already used another Plotly client, you probably do not need to do this.
## Your first graph
To create a graph on the Plotly servers, start by importing the client:
```scala
import co.theasi.plotly._
```Then, just pass the *x*, *y* series that you want to plot:
```scala
scala> val x = Vector(1.0, 2.0, 3.0)scala> val y = Vector(1.0, 4.0, 9.0)
scala> val p = Plot().withScatter(x, y)
scala> draw(p, "hello-plotly")
PlotFile = PlotFile(pbugnion:264,hello-plotly)
```This will create a graph called `hello-plotly` in your account!
## Using custom credentials
Sometimes, creating a `~/.plotly/.credentials` file isn't practical. In that case, you can pass credentials to Plotly programatically by defining a custom server.
```scala
import co.theasi.plotly._implicit val server = new writer.Server {
val credentials = writer.Credentials("", "")
val url = "https://api.plot.ly/v2/"
}
```You can then use Plotly commands normally:
```scala
scala> val p = Plot().withScatter(Vector(1, 2, 3), Vector(1, 4, 9))scala> draw(p, "custom-credentials")
PlotFile = PlotFile(pbugnion:268,custom-credentials)
```