Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sl/syncplots #21

Merged
merged 12 commits into from
Mar 2, 2016
30 changes: 10 additions & 20 deletions examples/3d.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using PlotlyJS

function random_line(showme=true)
function random_line()
n = 400
rw() = cumsum(randn(n))
trace1 = scatter3d(;x=rw(),y=rw(), z=rw(), mode="lines",
Expand All @@ -20,12 +20,10 @@ function random_line(showme=true)
line_color="#bcbd22", line_width=1)
layout = Layout(autosize=false, width=500, height=500,
margin=Dict(:l => 0, :r => 0, :b => 0, :t => 65))
p = Plot([trace1, trace2, trace3], layout)
showme && show(p)
p
plot([trace1, trace2, trace3], layout)
end

function topo_surface(showme=true)
function topo_surface()
z = Vector[[27.80985, 49.61936, 83.08067, 116.6632, 130.414, 150.7206, 220.1871,
156.1536, 148.6416, 203.7845, 206.0386, 107.1618, 68.36975, 45.3359,
49.96142, 21.89279, 17.02552, 11.74317, 14.75226, 13.6671, 5.677561,
Expand Down Expand Up @@ -117,12 +115,10 @@ function topo_surface(showme=true)
layout = Layout(title="Mt. Bruno Elevation", autosize=false, width=500,
height=500,
margin=Dict(:l => 65, :r => 50, :b => 65, :t => 90))
p = Plot(trace, layout)
showme && show(p)
p
plot(trace, layout)
end

function multiple_surface(showme=true)
function multiple_surface()
z1 = Vector[[8.83, 8.89, 8.81, 8.87, 8.9, 8.87],
[8.89, 8.94, 8.85, 8.94, 8.96, 8.92],
[8.84, 8.9, 8.82, 8.92, 8.93, 8.91],
Expand All @@ -143,12 +139,10 @@ function multiple_surface(showme=true)
trace1 = surface(z=z1)
trace2 = surface(z=z2, showscale=false, opacity=0.9)
trace3 = surface(z=z3, showscale=false, opacity=0.9)
p = Plot([trace1, trace2, trace3])
showme && show(p)
p
plot([trace1, trace2, trace3])
end

function clustering_alpha_shapes(showme=true)
function clustering_alpha_shapes()
@eval using DataFrames, RDatasets, Colors

# load data
Expand Down Expand Up @@ -187,12 +181,10 @@ function clustering_alpha_shapes(showme=true)
:backgroundcolor=>"rgb(230, 230,230)"),
:aspectratio=>Dict( :x=>1, :y=>1, :z=>0.7 ),
:aspectmode => "manual"))
p = Plot(data, layout)
showme && show(p)
p
plot(data, layout)
end

function scatter_3d(showme=true)
function scatter_3d()
@eval using Distributions
Σ = fill(0.5, 3, 3) + Diagonal([0.5, 0.5, 0.5])
obs1 = rand(MvNormal(zeros(3), Σ), 200)'
Expand All @@ -211,7 +203,5 @@ function scatter_3d(showme=true)

layout = Layout(margin=Dict(:l=>0, :r=>0, :t=>0, :b=>0))

p = Plot([trace1, trace2], layout)
showme && show(p)
p
plot([trace1, trace2], layout)
end
20 changes: 7 additions & 13 deletions examples/area.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using PlotlyJS

function area1(showme=true)
function area1()
trace1 = scatter(;x=1:4, y=[0, 2, 3, 5], fill="tozeroy")
trace2 = scatter(;x=1:4, y=[3, 5, 1, 7], fill="tonexty")
p = Plot([trace1, trace2])
showme && show(p)
p
plot([trace1, trace2])
end

function stacked_area!(traces)
Expand All @@ -17,23 +15,19 @@ function stacked_area!(traces)
traces
end

function area2(showme=true)
function area2()
traces = [scatter(;x=1:3, y=[2, 1, 4], fill="tozeroy"),
scatter(;x=1:3, y=[1, 1, 2], fill="tonexty"),
scatter(;x=1:3, y=[3, 0, 2], fill="tonexty")]
stacked_area!(traces)

p = Plot(traces, Layout(title="stacked and filled line chart"))
showme && show(p)
p
plot(traces, Layout(title="stacked and filled line chart"))
end


function area3(showme=true)
function area3()
trace1 = scatter(;x=1:4, y=[0, 2, 3, 5], fill="tozeroy", mode="none")
trace2 = scatter(;x=1:4, y=[3, 5, 1, 7], fill="tonexty", mode="none")
p = Plot([trace1, trace2],
Layout(title="Overlaid Chart Without Boundary Lines"))
showme && show(p)
p
plot([trace1, trace2],
Layout(title="Overlaid Chart Without Boundary Lines"))
end
6 changes: 2 additions & 4 deletions examples/contour.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using PlotlyJS

function contour1(showme=false)
function contour1()
x = [-9, -6, -5 , -3, -1]
y = [0, 1, 4, 5, 7]
z = [10 10.625 12.5 15.625 20
Expand All @@ -11,7 +11,5 @@ function contour1(showme=false)
trace = contour(x=x, y=y, z=z)

layout = Layout(title="Setting the X and Y Coordinates in a Contour Plot")
p = Plot(trace, layout)
showme && show(p)
p
plot(trace, layout)
end
8 changes: 3 additions & 5 deletions examples/histograms.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
# module ContourExamples
using PlotlyJS

function example3()
function two_hists()
x0 = randn(500)
x1 = x0+1

trace1 = histogram(x=x0, opacity=0.75)
trace2 = histogram(x=x1, opacity=0.75)
data = [trace1, trace2]
layout = Layout(barmode="overlay")
p = Plot(data, layout); show(p); p
plot(data, layout)
end

# end # module
36 changes: 12 additions & 24 deletions examples/line_scatter.jl
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
using PlotlyJS

function linescatter1(showme=true)
function linescatter1()
trace1 = scatter(;x=1:4, y=[10, 15, 13, 17], mode="markers")
trace2 = scatter(;x=2:5, y=[16, 5, 11, 9], mode="lines")
trace3 = scatter(;x=1:4, y=[12, 9, 15, 12], mode="lines+markers")
p = Plot([trace1, trace2, trace3])
showme && show(p)
p
plot([trace1, trace2, trace3])
end

function linescatter2(showme=true)
function linescatter2()
trace1 = scatter(;x=1:5, y=[1, 6, 3, 6, 1],
mode="markers", name="Team A",
text=["A-1", "A-2", "A-3", "A-4", "A-5"],
Expand All @@ -24,12 +22,10 @@ function linescatter2(showme=true)
data = [trace1, trace2]
layout = Layout(;title="Data Labels Hover", xaxis_range=[0.75, 5.25],
yaxis_range=[0, 8])
p = Plot(data, layout)
showme && show(p)
p
plot(data, layout)
end

function linescatter3(showme=true)
function linescatter3()
trace1 = scatter(;x=1:5, y=[1, 6, 3, 6, 1],
mode="markers+text", name="Team A",
textposition="top center",
Expand All @@ -48,21 +44,17 @@ function linescatter3(showme=true)
yaxis_range=[0, 8], legend_y=0.5, legend_yref="paper",
legend_font=Dict(:family => "Arial, sans-serif", :size => 20,
:color => "grey"))
p = Plot(data, layout)
showme && show(p)
p
plot(data, layout)
end

function linescatter4(showme=true)
function linescatter4()
trace1 = scatter(;y=fill(5, 40), mode="markers", marker_size=40,
marker_color=0:39)
layout = Layout(title="Scatter Plot with a Color Dimension")
p = Plot(trace1, layout)
showme && show(p)
p
plot(trace1, layout)
end

function linescatter5(showme=true)
function linescatter5()

country = ["Switzerland (2011)", "Chile (2013)", "Japan (2014)",
"United States (2012)", "Slovenia (2014)", "Canada (2011)",
Expand Down Expand Up @@ -107,12 +99,10 @@ function linescatter5(showme=true)
layout["legend"] = Dict(:font => Dict(:size => 10),
:yanchor => "middle",
:xanchor => "right")
p = Plot(data, layout)
showme && show(p)
p
plot(data, layout)
end

function linescatter6(showme=true)
function linescatter6()
trace1 = scatter(;x=[52698, 43117], y=[53, 31],
mode="markers",
name="North America",
Expand Down Expand Up @@ -149,7 +139,5 @@ function linescatter6(showme=true)
layout["xaxis"] = Dict(:title => "GDP per Capita", :showgrid => false, :zeroline => false)
layout["yaxis"] = Dict(:title => "Percent", :showline => false)

p = Plot(data, layout)
showme && show(p)
p
plot(data, layout)
end
12 changes: 4 additions & 8 deletions examples/maps.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using PlotlyJS

function maps1(showme=true)
function maps1()
marker = Dict(:size=>[20, 30, 15, 10],
:color=>[10, 20, 40, 50],
:cmin=>0,
Expand All @@ -14,12 +14,10 @@ function maps1(showme=true)
marker=marker, name="Europe Data")
layout = Layout(geo_scope="europe", geo_resolution=50, width=500, height=550,
margin=Dict(:l=>0, :r=>0, :t=>10, :b=>0))
p = Plot(trace, layout)
showme && show(p)
p
plot(trace, layout)
end

function maps2(showme=true)
function maps2()
@eval using DataFrames

# read Data into dataframe
Expand All @@ -46,7 +44,5 @@ function maps2(showme=true)
:countrycolor => "rgb(255,255,255)")

layout = Layout(;title="2014 US City Populations", showlegend=false, geo=geo)
p = Plot(trace, layout)
showme && show(p)
p
plot(trace, layout)
end
Loading