Commit b41e21a9 authored by Jayant Khatkar's avatar Jayant Khatkar
Browse files

switch to plotly, 3d plot of contours

parent 2166e877
......@@ -30,7 +30,7 @@ construct_cost(cdata, vd, ABS, td, :cost_f)
c = cost_f(rl)
# local search loop
k = 5 # TODO k is hardcoded in function below (uses global variable)
k = 150 # TODO k is hardcoded in function below (uses global variable)
function best_neighbor!(rl::Vector{Int}, current_cost::Number)
costs = Dict()
for i in 1:1:length(rl)-1
......@@ -98,4 +98,6 @@ histogram(data) # vast majority of voxels near 0 stress - can ignore
histogram!(sort(data, rev=true)[1:4000]) # vast majority of voxels near 0 stress - can ignore
### Visualise voxmap
plot(vd, 35, cdata)
\ No newline at end of file
plot(vd, 46, cdata)
plot(Vector(1:length(rl)), cdata)
plot(rl, cdata)
\ No newline at end of file
......@@ -5,9 +5,10 @@ using LightGraphs
using NearestNeighbors
using Statistics
using BenchmarkTools
using Plots
using LinearAlgebra
import Plots: plot, plot!
using PlotlyJS
import PlotlyJS: plot
using Colors
struct material
......@@ -582,12 +583,43 @@ function plot(vd::voxdata, i::Int, cdata::contourdata)
sq_x = [loc[1]-w, loc[1]-w, loc[1]+w, loc[1]+w, loc[1]-w]
sq_y = [loc[2]+w, loc[2]-w, loc[2]-w, loc[2]+w, loc[2]+w]
plt = plot(sq_x, sq_y, aspect_ratio=:equal, label="Voxel", lw=3, color="black")
traces = Vector{GenericTrace}()
push!(traces, scatter(x=sq_x, y=sq_y,
mode="lines",
name="Voxel",
line=attr(color="black", width=4)
))
for (c,l) in zip(vm.segcontours, vm.seglen)
plot!(plt,
cdata.contours[c].pos[:,1],
cdata.contours[c].pos[:,2],
label=l)
push!(traces, scatter(
x=cdata.contours[c].pos[:,1],
y=cdata.contours[c].pos[:,2],
mode="lines",
name=round(l;digits=2)))
end
plt
layout = Layout(
yaxis=attr(scaleanchor="x", scaleratio=1)
)
plot(traces, layout)
end
function plot(rl::Vector{Int}, cdata::contourdata)
n = length(rl)
cols = range(HSV(0,1,1), stop=HSV(-360,1,1), length=n)
traces = Vector{GenericTrace}()
layout = Layout(
yaxis=attr(scaleanchor="x", scaleratio=1)
)
for i in 1:n
push!(traces, scatter(
x=cdata.contours[rl[i]].pos[:,1],
y=cdata.contours[rl[i]].pos[:,2],
z=cdata.contours[rl[i]].pos[:,3],
mode="lines",
type="scatter3d",
line=attr(color=cols[i])
))
end
plot(traces, layout)
end
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment