From 45bf4b849d6de583624e3b8aba19fe479d1e7185 Mon Sep 17 00:00:00 2001 From: AtilaSaraiva Date: Sun, 17 Nov 2024 18:50:17 -0700 Subject: [PATCH 1/3] adding support for transparency to seisimageplot and seisoverlayplot --- src/Recipes/SeisImageRecipe.jl | 8 +++++--- src/Recipes/SeisOverlayRecipe.jl | 15 ++++++++++----- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/Recipes/SeisImageRecipe.jl b/src/Recipes/SeisImageRecipe.jl index d4ac830..3c20b57 100644 --- a/src/Recipes/SeisImageRecipe.jl +++ b/src/Recipes/SeisImageRecipe.jl @@ -45,6 +45,8 @@ Credits: Aaron Stanton (2015) vmax = nothing, cmap = :seismic, + transparency = false, + alpha = 1.0 ) end @@ -78,11 +80,11 @@ function Makie.plot!(img::SeisImagePlot{<:Tuple{AbstractMatrix{<:Real}}}) Makie.Observables.onany(update_plot, img.d, img.ox, img.oy, img.dx, img.dy, img.pclip, img.vmin, img.vmax) update_plot(img.d[], img.ox[], img.oy[], img.dx[], img.dy[], img.pclip[], img.vmin[], img.vmax[]) - + if (colorrange[][1] != colorrange[][2]) - image!(img, x, y, transposed_d, colorrange=colorrange, colormap=img.cmap) + image!(img, x, y, transposed_d, colorrange=colorrange, colormap=img.cmap, alpha=img.alpha, transparency=img.transparency) else - image!(img, x, y, transposed_d, colormap=img.cmap) + image!(img, x, y, transposed_d, colormap=img.cmap, alpha=img.alpha, transparency=img.transparency) end img end diff --git a/src/Recipes/SeisOverlayRecipe.jl b/src/Recipes/SeisOverlayRecipe.jl index f90312c..eec51ed 100644 --- a/src/Recipes/SeisOverlayRecipe.jl +++ b/src/Recipes/SeisOverlayRecipe.jl @@ -52,14 +52,17 @@ julia> ov = seisoverlay!(ax, d) vmin = nothing, vmax = nothing, - cmap = :seismic + cmap = :seismic, + + transparency = false, + alpha = 1.0 ) end function Makie.plot!(overlay::SeisOverlayPlot{<:Tuple{AbstractMatrix{<:Real}}}) clipped_d = Observable{Any}() - + function update_plot(d) # Clipping the negative values of the first wiggle clipped_d[] = copy(d) @@ -67,15 +70,17 @@ function Makie.plot!(overlay::SeisOverlayPlot{<:Tuple{AbstractMatrix{<:Real}}}) end Makie.Observables.onany(update_plot, overlay.d) - + update_plot(overlay.d[]) - + seisimageplot!(overlay, clipped_d, ox=overlay.ox, dx=overlay.dx, oy=overlay.oy, dy=overlay.dy, cmap=overlay.cmap, vmin=overlay.vmin, vmax=overlay.vmax, - pclip=overlay.pclip) + pclip=overlay.pclip, + alpha=overlay.alpha, + transparency=overlay.transparency) seiswiggleplot!(overlay, clipped_d, ox=overlay.ox, dx=overlay.dx, oy=overlay.oy, dy=overlay.dy, xcur=overlay.xcur, From 767c8a4a0a53a74c39acfa949b31fa15c86990a1 Mon Sep 17 00:00:00 2001 From: AtilaSaraiva Date: Sun, 17 Nov 2024 18:50:42 -0700 Subject: [PATCH 2/3] adding support for transparency to seisPlotTX.jl --- src/seisPlotTX.jl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/seisPlotTX.jl b/src/seisPlotTX.jl index 1372c98..6b804f2 100644 --- a/src/seisPlotTX.jl +++ b/src/seisPlotTX.jl @@ -11,7 +11,7 @@ Plot time-space, 2D seismic data `d` with image, wiggles or overlay. # Keyword Arguments: - `fig=nothing`: the figure we want to plot on. If not supplied, one will be created and returned. -- `gx::Vector{<:Real}=nothing`: the real coordinates of the seismometers corresponding to the traces in d. Only +- `gx::Vector{<:Real}=nothing`: the real coordinates of the seismometers corresponding to the traces in d. Only supported with style="wiggles" - `ox=0`: first point of x-axis. - `dx=1`: increment of x-axis. @@ -45,7 +45,7 @@ function seisPlotTX(d; fig=nothing, ax=nothing, gx=nothing, ox=0, dx=1, oy=0, dy=1, xcur=1.2, wiggle_trace_increment=1, pclip=98, vmin=nothing, vmax=nothing, wiggle_line_color=:black, wiggle_fill_color=:black, trace_width=0.7, - cmap=:seismic, style="image") + cmap=:seismic, style="image", alpha::AbstractFloat=1.0, transparency=false) if isnothing(fig) fig = Figure() @@ -61,7 +61,8 @@ function seisPlotTX(d; wiggle_trace_increment=wiggle_trace_increment, wiggle_line_color=wiggle_line_color, wiggle_fill_color=wiggle_fill_color, - trace_width=trace_width, cmap=cmap) + trace_width=trace_width, cmap=cmap, + transparency=false, alpha=1.0) Colorbar(fig[1, 2], overlay) @@ -85,7 +86,8 @@ function seisPlotTX(d; xlims!(ax, low=start-diff, high=start + size(to_value(d), 2)*diff) else - img = seisimageplot!(ax, d; ox=ox, dx=dx, oy=oy, dy=dy, pclip=pclip, vmin=vmin, vmax=vmax, cmap=cmap) + img = seisimageplot!(ax, d; ox=ox, dx=dx, oy=oy, dy=dy, pclip=pclip, vmin=vmin, vmax=vmax, + cmap=cmap, alpha=alpha, transparency=transparency) Colorbar(fig[1,2], img) xlims!(ax, low=to_value(ox), high=to_value(ox)+size(to_value(d),2)*to_value(dx)) From 9f7334188f0bb8f59dc44d8e2987bac569d90c06 Mon Sep 17 00:00:00 2001 From: AtilaSaraiva Date: Sun, 17 Nov 2024 19:27:03 -0700 Subject: [PATCH 3/3] adding support for transparency to seisPlotFK.jl --- src/seisPlotFK.jl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/seisPlotFK.jl b/src/seisPlotFK.jl index 43345c3..339404d 100644 --- a/src/seisPlotFK.jl +++ b/src/seisPlotFK.jl @@ -31,7 +31,8 @@ julia> f, ax = SeisPlotFK(d); Author: Firas Al Chalabi (2024) """ function seisPlotFK(d; fig=nothing, dx=1, dy=1, fmax=100, - pclip=99.9, vmin=nothing, vmax=nothing, cmap=:PuOr) + pclip=99.9, vmin=nothing, vmax=nothing, cmap=:PuOr, + transparency=false, alpha=1.0) if isnothing(fig) fig = Figure() @@ -39,7 +40,7 @@ function seisPlotFK(d; fig=nothing, dx=1, dy=1, fmax=100, ax = __create_axis(fig[1, 1]) - img = seisfkplot!(ax, d, dx=dx, dy=dy, fmax=fmax, pclip=pclip, vmin=vmin, vmax=vmax, cmap=cmap) + img = seisfkplot!(ax, d, dx=dx, dy=dy, fmax=fmax, pclip=pclip, vmin=vmin, vmax=vmax, cmap=cmap, alpha=alpha, transparency=transparency) Colorbar(fig[1,2], img) ax.xlabel = "Wavenumber (1/m)"