Skip to content

Commit

Permalink
Merge pull request #32 from AtilaSaraiva/transparency
Browse files Browse the repository at this point in the history
Transparency support
  • Loading branch information
AtilaSaraiva authored Nov 20, 2024
2 parents 660b595 + 9f73341 commit fba5973
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 14 deletions.
8 changes: 5 additions & 3 deletions src/Recipes/SeisImageRecipe.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ Credits: Aaron Stanton (2015)
vmax = nothing,

cmap = :seismic,
transparency = false,
alpha = 1.0
)
end

Expand Down Expand Up @@ -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
15 changes: 10 additions & 5 deletions src/Recipes/SeisOverlayRecipe.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,30 +52,35 @@ 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)
clipped_d[][:, 1] = max.(clipped_d[][:, 1], 0)
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,
Expand Down
5 changes: 3 additions & 2 deletions src/seisPlotFK.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,16 @@ 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()
end

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)"
Expand Down
10 changes: 6 additions & 4 deletions src/seisPlotTX.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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()
Expand All @@ -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)

Expand All @@ -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))
Expand Down

0 comments on commit fba5973

Please sign in to comment.