Skip to main content

PlotlyJS

Plotly Library

We provide direct bindings to API of Plotly.js. Try out some the of basic charts

Download original notebook
data = Table[{x, Sinc[6x]}, {x,0, 2Pi, 0.1}];

plot = Plotly[<|
  "x"->data[[All,1]],
  "y"->data[[All,2]],
  "mode"->"lines"
|>]
(*VB[*)(FrontEndRef["5cab97be-7f56-411c-8c51-a034f8e5778f"])(*,*)(*"1:eJxTTMoPSmNkYGAoZgESHvk5KRCeEJBwK8rPK3HNS3GtSE0uLUlMykkNVgEKmyYnJlmaJ6XqmqeZmumaGBom61okmxrqJhoYm6RZpJqam1ukAQCKiBWz"*)(*]VB*)

Now plot acts like an instance of the visible plot. To add more traces simply evaluate:

PlotlyAddTraces[plot, {
  <|"x"->data[[All,1]], "y"->Reverse[data[[All,2]]]|>
}]

Plotly automatically rescales and adds legends. This can be done with almost any plot type.

Other charts

Pie, bars, bubble chart. Plotly has almost everything!

trace = <| 
	"values" -> {19, 26, 55}, 
	"labels" -> {"Residential", "Non-Residential", "Utility"}, 
	"type" -> "pie" 
|>;

Plotly[trace]
(*VB[*)(FrontEndRef["998b6f51-7417-4614-a53e-9abf4aec1b1f"])(*,*)(*"1:eJxTTMoPSmNkYGAoZgESHvk5KRCeEJBwK8rPK3HNS3GtSE0uLUlMykkNVgEKW1paJJmlmRrqmpsYmuuamBma6CaaGqfqWiYmpZkkpiYbJhmmAQB40RWq"*)(*]VB*)
trace = <| 
	"x" -> {"giraffes", "orangutans", "monkeys"}, 
	"y" -> {20, 14, 23}, "type" -> "bar" 
|>;

Plotly[trace] 
(*VB[*)(FrontEndRef["a5204aec-183f-42a7-819a-2796b31cd9fa"])(*,*)(*"1:eJxTTMoPSmNkYGAoZgESHvk5KRCeEJBwK8rPK3HNS3GtSE0uLUlMykkNVgEKJ5oaGZgkpibrGloYp+maGCWa61oYWibqGplbmiUZGyanWKYlAgCAhBWg"*)(*]VB*)
trace = <|
	"x" -> {1, 2, 3, 4}, 
	"y" -> {10, 11, 12, 13}, 
	"mode" -> "markers", 
	"marker" -> <| "size" -> {40, 60, 80, 100} |> 
|>;

Plotly[trace]
(*VB[*)(FrontEndRef["89322229-2393-4060-99a1-f0e3d4695046"])(*,*)(*"1:eJxTTMoPSmNkYGAoZgESHvk5KRCeEJBwK8rPK3HNS3GtSE0uLUlMykkNVgEKW1gaGwGBpa6RsaWxromBmYGupWWioW6aQapxiomZpamBiRkAZGUUKw=="*)(*]VB*)
heatmap = <|
	"z" -> Table[x y, {x,-10,10}, {y,-10,10}],
	"type" -> "heatmap"
|>;

Plotly[heatmap]
(*VB[*)(FrontEndRef["cf3f833e-a0af-46f0-ab3b-8d1f765d5be1"])(*,*)(*"1:eJxTTMoPSmNkYGAoZgESHvk5KRCeEJBwK8rPK3HNS3GtSE0uLUlMykkNVgEKJ6cZp1kYG6fqJhokpumamKUZ6CYmGSfpWqQYppmbmaaYJqUaAgCUTxZe"*)(*]VB*)