From d6b0d4bcfa55288b85486282a36d8271b9673daf Mon Sep 17 00:00:00 2001 From: "Velimir (monty) Vesselinov" Date: Wed, 17 Jul 2024 16:22:42 -0600 Subject: [PATCH] plotly fix --- src/NMFkHelpers.jl | 4 ++-- src/NMFkMap.jl | 4 ++-- src/NMFkPlotWell.jl | 18 +++++++++--------- src/NMFkProgressive.jl | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/NMFkHelpers.jl b/src/NMFkHelpers.jl index 648ddfd..8fbb8bd 100644 --- a/src/NMFkHelpers.jl +++ b/src/NMFkHelpers.jl @@ -481,10 +481,10 @@ function remap(v::AbstractVector, vi::Union{AbstractVector,AbstractUnitRange,Ste end function stringproduct(a::AbstractVector, b::AbstractVector) - M = Matrix{eltype(a)}(undef, length(a), length(b)) + M = Matrix{String}(undef, length(a), length(b)) for i = eachindex(a) for j = eachindex(b) - M[i, j] = a[i] * ":" * b[j] + M[i, j] = string(a[i]) * ":" * string(b[j]) end end return M diff --git a/src/NMFkMap.jl b/src/NMFkMap.jl index c0c283b..42cd49d 100644 --- a/src/NMFkMap.jl +++ b/src/NMFkMap.jl @@ -154,7 +154,7 @@ function plotmap(x::AbstractVector{T}, y::AbstractVector{T}, c::AbstractVector{T lat=y, hoverinfo="text", text=text, - marker=Plotly.attr(; size=size, color=c, colorscale=NMFk.colorscale(:rainbow), colorbar=Plotly.attr(; thickness=20, width=100), line_width=0, line_color="black")) + marker=PlotlyJS.attr(; size=size, color=c, colorscale=NMFk.colorscale(:rainbow), colorbar=PlotlyJS.attr(; thickness=20, width=100), line_width=0, line_color="black")) geo = PlotlyJS.attr(scope="usa", projection_type="albers usa", showland=true, @@ -187,7 +187,7 @@ function plotmap(x::AbstractVector{T1}, y::AbstractVector{T1}, c::AbstractVector hoverinfo="text", text=text[iz], name="$i $(sum(iz))", - marker=Plotly.attr(; size=size, color=NMFk.colors[k])) + marker=PlotlyJS.attr(; size=size, color=NMFk.colors[k])) push!(traces, trace) end geo = PlotlyJS.attr(scope="usa", diff --git a/src/NMFkPlotWell.jl b/src/NMFkPlotWell.jl index 127cab0..b709510 100644 --- a/src/NMFkPlotWell.jl +++ b/src/NMFkPlotWell.jl @@ -21,7 +21,7 @@ function plot_dots(x::AbstractVector, y::AbstractVector, z::AbstractVector; hove l = isnothing(label) ? Dict(:mode=>"markers") : Dict(:mode=>"markers+text", :text=>label, :textposition=>"left center") if eltype(z) <: AbstractFloat h = isnothing(hover) ? Dict() : Dict(:hovertext=>hover, :hoverinfo=>"text") - p = PlotlyJS.scatter(; x=x, y=y, z=z, l..., marker=Plotly.attr(; size=pointsize, color=z, colorscale=colorscale(:rainbow), colorbar=Plotly.attr(; thickness=20)), h...) + p = PlotlyJS.scatter(; x=x, y=y, z=z, l..., marker=PlotlyJS.attr(; size=pointsize, color=z, colorscale=colorscale(:rainbow), colorbar=PlotlyJS.attr(; thickness=20)), h...) else dots = [] uz = unique(sort(z)) @@ -37,7 +37,7 @@ function plot_dots(x::AbstractVector, y::AbstractVector, z::AbstractVector; hove h = isnothing(hover) ? Dict() : Dict(:hovertext=>hover[iz], :hoverinfo=>"text") jj = j % length(NMFk.colors) c = jj == 0 ? length(NMFk.colors) : jj - dots_p = PlotlyJS.scatter(; x=x[iz], y=y[iz], l..., name="$i $(sum(iz))", marker=Plotly.attr(; size=pointsize), color=NMFk.colors[c], h...) + dots_p = PlotlyJS.scatter(; x=x[iz], y=y[iz], l..., name="$i $(sum(iz))", marker=PlotlyJS.attr(; size=pointsize), color=NMFk.colors[c], h...) push!(dots, dots_p) end p = convert(Vector{typeof(dots[1])}, dots) @@ -77,7 +77,7 @@ function plot_wells(wx::AbstractVector, wy::AbstractVector, c::AbstractVector; h ic = c .== i l = isnothing(label) ? Dict(:mode=>"markers") : Dict(:mode=>"markers+text", :text=>label, :textposition=>"left center") h = isnothing(hover) ? Dict() : Dict(:hovertext=>hover[ic], :hoverinfo=>"text") - well_p = PlotlyJS.scatter(;x=wx[ic], y=wy[ic], l..., name="$i $(sum(ic))", marker_color=NMFk.colors[j], marker=Plotly.attr(; size=pointsize), h...) + well_p = PlotlyJS.scatter(;x=wx[ic], y=wy[ic], l..., name="$i $(sum(ic))", marker_color=NMFk.colors[j], marker=PlotlyJS.attr(; size=pointsize), h...) push!(wells, well_p) end return convert(Vector{typeof(wells[1])}, wells) @@ -94,7 +94,7 @@ function plot_wells(wx::AbstractVector, wy::AbstractVector, wz::AbstractVector, for (j, i) in enumerate(unique(sort(c))) ic = c .== i h = isnothing(hover) ? Dict() : Dict(:hovertext=>hover[ic], :hoverinfo=>"text") - well_p = PlotlyJS.scatter3d(;x=wx[ic], y=wy[ic], z=wz[ic], mode="markers", name="$i $(sum(ic))", marker_color=NMFk.colors[j], marker=Plotly.attr(; size=pointsize), h...) + well_p = PlotlyJS.scatter3d(;x=wx[ic], y=wy[ic], z=wz[ic], mode="markers", name="$i $(sum(ic))", marker_color=NMFk.colors[j], marker=PlotlyJS.attr(; size=pointsize), h...) push!(wells, well_p) end return convert(Vector{typeof(wells[1])}, wells) @@ -109,7 +109,7 @@ function plot_heel_toe_bad(heel_x::AbstractVector, heel_y::AbstractVector, toe_x tx = toe_x[ic] ty = toe_y[ic] for k = eachindex(hx) - well_trace = PlotlyJS.scatter(;x=[hx[k], tx[k]], y=[ty[k], ty[k]], mode="lines+markers", marker_color=NMFk.colors[j], marker=Plotly.attr(size=6), line=Plotly.attr(width=2, color=NMFk.colors[j]), transform=Plotly.attr(type="groupby", groups=fill(i, length(hx)), styles=Plotly.attr(target="$i $(sum(ic))")), color=NMFk.colors[j]) + well_trace = PlotlyJS.scatter(;x=[hx[k], tx[k]], y=[ty[k], ty[k]], mode="lines+markers", marker_color=NMFk.colors[j], marker=PlotlyJS.attr(size=6), line=PlotlyJS.attr(width=2, color=NMFk.colors[j]), transform=PlotlyJS.attr(type="groupby", groups=fill(i, length(hx)), styles=PlotlyJS.attr(target="$i $(sum(ic))")), color=NMFk.colors[j]) push!(wells, well_trace) end end @@ -135,9 +135,9 @@ function plot_heel_toe(heel_x::AbstractVector, heel_y::AbstractVector, toe_x::Ab y = vec(hcat([[hy[i] ty[i] NaN] for i = eachindex(hy)]...)) if !isnothing(hover) h = vec(hcat([[hover[i] hover[i] NaN] for i = eachindex(hover)]...)) - well_trace = PlotlyJS.scatter(;x=x, y=y, hovertext=h, mode="lines+markers", name="$i $(sum(ic))", marker_color=NMFk.colors[j], marker=Plotly.attr(size=6), line=Plotly.attr(width=2, color=NMFk.colors[j])) + well_trace = PlotlyJS.scatter(;x=x, y=y, hovertext=h, mode="lines+markers", name="$i $(sum(ic))", marker_color=NMFk.colors[j], marker=PlotlyJS.attr(size=6), line=PlotlyJS.attr(width=2, color=NMFk.colors[j])) else - well_trace = PlotlyJS.scatter(;x=x, y=y, mode="lines+markers", name="$i $(sum(ic))", marker_color=NMFk.colors[j], marker=Plotly.attr(size=6), line=Plotly.attr(width=2, color=NMFk.colors[j])) + well_trace = PlotlyJS.scatter(;x=x, y=y, mode="lines+markers", name="$i $(sum(ic))", marker_color=NMFk.colors[j], marker=PlotlyJS.attr(size=6), line=PlotlyJS.attr(width=2, color=NMFk.colors[j])) end push!(traces, well_trace) end @@ -166,9 +166,9 @@ function plot_heel_toe(heel_x::AbstractVector, heel_y::AbstractVector, heel_z::A z = vec(hcat([[hz[i] tz[i] NaN] for i = eachindex(hz)]...)) if !isnothing(hover) h = vec(hcat([[hover[i] hover[i] NaN] for i = eachindex(hover)]...)) - well_trace = PlotlyJS.scatter3d(;x=x, y=y, z=z, hovertext=h, mode="lines", name="$i $(sum(ic))", marker_color=NMFk.colors[j], line=Plotly.attr(width=6, color=NMFk.colors[j])) + well_trace = PlotlyJS.scatter3d(;x=x, y=y, z=z, hovertext=h, mode="lines", name="$i $(sum(ic))", marker_color=NMFk.colors[j], line=PlotlyJS.attr(width=6, color=NMFk.colors[j])) else - well_trace = PlotlyJS.scatter3d(;x=x, y=y, z=z, mode="lines", name="$i $(sum(ic))", marker_color=NMFk.colors[j], line=Plotly.attr(width=6, color=NMFk.colors[j])) + well_trace = PlotlyJS.scatter3d(;x=x, y=y, z=z, mode="lines", name="$i $(sum(ic))", marker_color=NMFk.colors[j], line=PlotlyJS.attr(width=6, color=NMFk.colors[j])) end push!(traces, well_trace) end diff --git a/src/NMFkProgressive.jl b/src/NMFkProgressive.jl index a254c3b..ad5ec4e 100644 --- a/src/NMFkProgressive.jl +++ b/src/NMFkProgressive.jl @@ -239,7 +239,7 @@ function progressive(syears::AbstractVector, eyears::AbstractVector, df::DataFra JLD2.save("$(resultdir)-$(problem)/gas_$(period)_$(ds[j])-$(dk[j])-$(nNMF)-assignments.jld2", "c_gas", c_gas) end - p = PlotlyJS.plot(NMFk.plot_wells(well_x, well_y, c_gas; hover=hovertext), Plotly.Layout(title="Gas $(period): $(dk[j]) types")) + p = PlotlyJS.plot(NMFk.plot_wells(well_x, well_y, c_gas; hover=hovertext), PlotlyJS.Layout(title="Gas $(period): $(dk[j]) types")) PlotlyJS.savehtml(p, "$(figuredirresults)-$(problem)/data-$(ds[j])-$(dk[j])-$(nNMF)-$(period_pred).html", :remote) for ct in sort(unique(c_gas))