facultyai / scala-plotly-client Goto Github PK
View Code? Open in Web Editor NEWVisualise your data from Scala using Plotly
Home Page: https://facultyai.github.io/scala-plotly-client/
License: MIT License
Visualise your data from Scala using Plotly
Home Page: https://facultyai.github.io/scala-plotly-client/
License: MIT License
If the data is already in Plotly, the user should be able to give srcs rather than a data array.
It would be nice to be able to reproduce these plots.
When trying to create a surface plot following the ThreeDPlot documentation, draw
throws an IllegalArgumentException
for me:
scala> val xs = Vector(-1.0, 0.0, 1.0)
xs: scala.collection.immutable.Vector[Double] = Vector(-1.0, 0.0, 1.0)
scala> val ys = Vector(0.0, 10.0)
ys: scala.collection.immutable.Vector[Double] = Vector(0.0, 10.0)
scala> val zs = Vector(Vector(1.0, 2.0, 1.0), Vector(5,0, 4.0, 5.0))
zs: scala.collection.immutable.Vector[scala.collection.immutable.Vector[Double]] = Vector(Vector(1.0, 2.0, 1.0), Vector(5.0, 0.0, 4.0, 5.0))
scala> val p = ThreeDPlot().withSurface(xs, ys, zs)
p: co.theasi.plotly.ThreeDPlot = ThreeDPlot(Vector(SurfaceXYZ(Vector(PDouble(-1.0), PDouble(0.0), PDouble(1.0)),Vector(PDouble(0.0), PDouble(10.0)),Vector(Vector(PDouble(1.0), PDouble(2.0), PDouble(1.0)), Vector(PDouble(5.0), PDouble(0.0), PDouble(4.0), PDouble(5.0))),SurfaceOptions(None,None,None,None))),ThreeDPlotOptions(AxisOptions(None,None,None,None,None,None,None,Font(None,None,None),Font(None,None,None),None,None,None,None),AxisOptions(None,None,None,None,None,None,None,Font(None,None,None),Font(None,None,None),None,None,None,None),AxisOptions(None,None,None,None,None,None,None,Font(None,None,None),Font(None,None,None),None,None,None,None)))
scala> draw(p, "foo")
java.lang.IllegalArgumentException: transpose requires all collections have the same size
at scala.collection.generic.GenericTraversableTemplate$class.fail$1(GenericTraversableTemplate.scala:213)
at scala.collection.generic.GenericTraversableTemplate$$anonfun$transpose$1$$anonfun$apply$1.apply(GenericTraversableTemplate.scala:220)
at scala.collection.generic.GenericTraversableTemplate$$anonfun$transpose$1$$anonfun$apply$1.apply(GenericTraversableTemplate.scala:219)
at scala.collection.immutable.List.foreach(List.scala:381)
at scala.collection.generic.GenericTraversableTemplate$$anonfun$transpose$1.apply(GenericTraversableTemplate.scala:219)
at scala.collection.generic.GenericTraversableTemplate$$anonfun$transpose$1.apply(GenericTraversableTemplate.scala:217)
at scala.collection.immutable.List.foreach(List.scala:381)
at scala.collection.generic.GenericTraversableTemplate$class.transpose(GenericTraversableTemplate.scala:217)
at scala.collection.AbstractTraversable.transpose(Traversable.scala:104)
at co.theasi.plotly.writer.FigureWriter$.co$theasi$plotly$writer$FigureWriter$$seriesToColumns(FigureWriter.scala:99)
at co.theasi.plotly.writer.FigureWriter$$anonfun$10.apply(FigureWriter.scala:73)
at co.theasi.plotly.writer.FigureWriter$$anonfun$10.apply(FigureWriter.scala:72)
at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:241)
at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:241)
at scala.collection.Iterator$class.foreach(Iterator.scala:893)
at scala.collection.AbstractIterator.foreach(Iterator.scala:1336)
at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
at scala.collection.TraversableLike$class.flatMap(TraversableLike.scala:241)
at scala.collection.AbstractTraversable.flatMap(Traversable.scala:104)
at co.theasi.plotly.writer.FigureWriter$.drawGrid(FigureWriter.scala:72)
at co.theasi.plotly.writer.FigureWriter$.draw(FigureWriter.scala:19)
at co.theasi.plotly.writer.ServerWriter$class.draw(ServerWriter.scala:26)
at co.theasi.plotly.package$.draw(package.scala:34)
at co.theasi.plotly.writer.ServerWriter$class.draw(ServerWriter.scala:44)
at co.theasi.plotly.package$.draw(package.scala:34)
at co.theasi.plotly.writer.ServerWriter$class.draw(ServerWriter.scala:34)
at co.theasi.plotly.package$.draw(package.scala:34)
... 42 elided
This is using master at cbdd2a7.
Nice lib!
It would be wonderful if we can plot data locally instead of sending over internet.
Something like this: https://plot.ly/python/offline/
Hi, I am getting this error when I tried to run the sample in your readme file.
"Exception in thread "main" java.lang.NoSuchMethodError: co.theasi.plotly.writer.Server.$init$(Lco/theasi/plotly/writer/Server;)V"
Platform: Windows 10
Scala version: Scala 2.10
Does scala plotly client work in Windows?
Plotly supports sending custom colorscales as well as the predefined ones. It might be nice to try and support that.
For instance, the following request body to the Plotly API seems to do what we expect (POST https://api.plot.ly/v2/plots
; you need to set the headers Plotly-Client-Platform
to something (eg. scala
), Content-Type
to application/json
and use basic auth with your username and password):
{
"figure":{
"data":[
{
"zsrc":"pbugnion:452:0049bf,2b5279,47daf1,964c04,6841d3,961eab",
"type":"heatmap",
"colorscale":[
[
7,
"rgb(165,0,38)"
],
[
7.1111111111111111,
"rgb(215,48,39)"
],
[
7.2222222222222222,
"rgb(244,109,67)"
],
[
7.3333333333333333,
"rgb(253,174,97)"
],
[
8.4444444444444444,
"rgb(254,224,144)"
],
[
8.5555555555555556,
"rgb(224,243,248)"
],
[
8.6666666666666666,
"rgb(171,217,233)"
],
[
8.7777777777777778,
"rgb(116,173,209)"
],
[
8.8888888888888888,
"rgb(69,117,180)"
],
[
9,
"rgb(49,54,149)"
]
]
}
]},
"world_readable":true
}
The colorscale
field seems to be an array of 2-arrays containing a z-value and a color.
I think the following interface would work:
// current interface in, eg. contour plots
val p = ThreeDPlot().withSurface(zs, SurfaceOptions().colorscale("Viridis"))
// extensions
val customColorscale = Coloscale.fromIterable(
List(7 -> Color.rgb(255, 0, 0), 7.5 -> Color.rgb(128, 128, 0), 8.0 -> Color.rgb(0, 255, 0))
)
val p = ThreeDPlot().withSurface(zs, SurfaceOptions().colorscale(customColorscale))
val customColorscale = Coloscale.fromFunction { z =>
if (z < 10.0) { Color.rgb(255, 0, 0) } else { Color.rgb(0, 255, 0) }
}
val p = ThreeDPlot().withSurface(zs, SurfaceOptions().colorscale(customColorscale))
It would be nice to be able to reproduce some of the map plots on here.
It would be nice to be able to reproduce these plots.
The last commit was two years ago and scala 2.13.1 has been released. Will there be support for that? thanks
Most of the functionality so far concentrates on plotting. It would be useful to add functionality to manipulate grids.
It would be nice to be able to reproduce these plots.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.