Skip to content

Commit

Permalink
alphas opacity plot
Browse files Browse the repository at this point in the history
  • Loading branch information
montyvesselinov committed Aug 9, 2024
1 parent 36c2c78 commit af14a93
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/MadsPlot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,7 @@ Dumps:
- Plots of data series
"""
function plotseriesengine(X::Union{AbstractMatrix,AbstractVector}, filename::AbstractString=""; nT::Integer=size(X, 1), nS::Integer=size(X, 2), format::AbstractString="", xtitle::AbstractString = "", ytitle::AbstractString = "", title::AbstractString="", logx::Bool=false, logy::Bool=false, keytitle::AbstractString="", name::AbstractString="Signal", names::Vector{String}=["$name $(i)" for i in 1:nS], combined::Bool=true, hsize::Measures.AbsoluteLength=8Gadfly.inch, vsize::Measures.AbsoluteLength=4Gadfly.inch, linewidth::Measures.AbsoluteLength=2Gadfly.pt, linestyle::Union{Symbol,AbstractVector}=:solid, pointsize::Measures.AbsoluteLength=2Gadfly.pt, key_position::Symbol=:right, major_label_font_size=14Gadfly.pt, minor_label_font_size=12Gadfly.pt, dpi::Integer=Mads.imagedpi, colors::Vector{String}=Mads.colors, opacity::Number=1.0, xmin::Any=nothing, xmax::Any=nothing, ymin::Any=nothing, ymax::Any=nothing, xaxis=1:nT, plotline::Bool=true, plotdots::Bool=!plotline, nextgray::Bool=false, lastcolored::Bool=false, code::Bool=false, returnplot::Bool=false, colorkey::Bool=(nS>ncolors) ? false : true, background_color=nothing, gm::Any=[], gl::Any=[], quiet::Bool=!Mads.graphoutput, truth::Bool=false, gall::Bool=false)
function plotseriesengine(X::Union{AbstractMatrix,AbstractVector}, filename::AbstractString=""; nT::Integer=size(X, 1), nS::Integer=size(X, 2), format::AbstractString="", xtitle::AbstractString = "", ytitle::AbstractString = "", title::AbstractString="", logx::Bool=false, logy::Bool=false, keytitle::AbstractString="", name::AbstractString="Signal", names::Vector{String}=["$name $(i)" for i in 1:nS], combined::Bool=true, hsize::Measures.AbsoluteLength=8Gadfly.inch, vsize::Measures.AbsoluteLength=4Gadfly.inch, linewidth::Measures.AbsoluteLength=2Gadfly.pt, linestyle::Union{Symbol,AbstractVector}=:solid, pointsize::Measures.AbsoluteLength=2Gadfly.pt, key_position::Symbol=:right, major_label_font_size=14Gadfly.pt, minor_label_font_size=12Gadfly.pt, dpi::Integer=Mads.imagedpi, colors::Vector{String}=Mads.colors, alpha::Number=0.2, alphas::AbstractVector=[alpha], xmin::Any=nothing, xmax::Any=nothing, ymin::Any=nothing, ymax::Any=nothing, xaxis=1:nT, plotline::Bool=true, plotdots::Bool=!plotline, nextgray::Bool=false, lastcolored::Bool=false, code::Bool=false, returnplot::Bool=false, colorkey::Bool=(nS>ncolors) ? false : true, background_color=nothing, gm::Any=[], gl::Any=[], quiet::Bool=!Mads.graphoutput, truth::Bool=false, gall::Bool=false)
if nT == 0 || nS == 0
@warn "Input is empty $(size(X)); a matrix or a vector is needed!"
return
Expand Down Expand Up @@ -1225,22 +1225,24 @@ function plotseriesengine(X::Union{AbstractMatrix,AbstractVector}, filename::Abs
if nextgray
cs = []
if lastcolored
default_colors = [[Colors.RGBA(parse(Colors.Colorant, "gray"), opacity) for i in 2:nS]; Colors.RGBA(parse(Colors.Colorant, colors[1]), opacity)]
default_colors = [[Colors.RGBA(parse(Colors.Colorant, "gray"), alpha) for i in 2:nS]; Colors.RGBA(parse(Colors.Colorant, colors[1]), alpha)]
else
default_colors = [Colors.RGBA(parse(Colors.Colorant, colors[1]), opacity); [Colors.RGBA(parse(Colors.Colorant, "gray"), opacity) for i in 2:nS]]
default_colors = [Colors.RGBA(parse(Colors.Colorant, colors[1]), alpha); [Colors.RGBA(parse(Colors.Colorant, "gray"), alpha) for i in 2:nS]]
end
else
if nS <= ncolors
cs = colorkey ? [Gadfly.Guide.manual_color_key(keytitle, names, [colors[i] for i in 1:nS])] : []
default_colors = [Colors.RGBA(parse(Colors.Colorant, colors[i]), opacity) for i in 1:nS]
default_colors = [Colors.RGBA(parse(Colors.Colorant, colors[i]), alpha) for i in 1:nS]
else
cs = colorkey ? [Gadfly.Guide.manual_color_key(keytitle, names, [colors[(i-1)%ncolors+1] for i in 1:nS])] : []
default_colors = [Colors.RGBA(parse(Colors.Colorant, colors[(i-1)%ncolors+1]), opacity) for i in 1:nS]
default_colors = [Colors.RGBA(parse(Colors.Colorant, colors[(i-1)%ncolors+1]), alpha) for i in 1:nS]
end
end
# RGBA does not impact opacity
# Gadfly.There alphas impact opacity
c = [Gadfly.layer(x=xaxis, y=X[:,i],
geometry[i]...,
Gadfly.Theme(line_width=linewidthea[i], line_style=[linestylea[i]], point_size=pointsize, highlight_width=0Gadfly.pt, discrete_highlight_color=c->nothing, default_color=default_colors[i]))
Gadfly.Theme(line_width=linewidthea[i], line_style=[linestylea[i]], point_size=pointsize, highlight_width=0Gadfly.pt, discrete_highlight_color=c->nothing, default_color=default_colors[i], alphas=alphas))
for i in 1:nS]...,
mck...,
gl...,
Expand Down

0 comments on commit af14a93

Please sign in to comment.