Skip to content

Adding uparrow as a predefined marker and creating unfilled markershapes #4977

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .zenodo.json
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,10 @@
"affiliation": "The Alan Turing Institute",
"name": "Penelope Yong",
"type": "Other"
},
{
"name": "Leon Becker",
"type": "Other"
}
],
"upload_type": "software"
Expand Down
5 changes: 5 additions & 0 deletions PlotsBase/ext/GRExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,9 @@ alignment(symb) =
end

# --------------------------------------------------------------------------------------
function gr_get_markershape(s::Symbol)
s in gr_markertypes ? s : Shape(s)
end

function gr_set_gradient(c)
grad = _as_gradient(c)
Expand Down Expand Up @@ -1263,6 +1266,7 @@ function gr_add_legend(sp, leg, viewport_area)

if (msh = series[:markershape]) ≢ :none
msz = max(first(series[:markersize]), 0)
msh = gr_get_markershape.(msh)
msw = max(first(series[:markerstrokewidth]), 0)
mfac = 0.8 * lfps / (msz + 0.5 * msw + 1e-20)
gr_draw_marker(
Expand Down Expand Up @@ -2047,6 +2051,7 @@ function gr_draw_markers(
ms = get_thickness_scaling(series) * _cycle(msize, i)
msw = get_thickness_scaling(series) * _cycle(strokewidth, i)
shape = _cycle(shapes, i)
shape = gr_get_markershape.(shape)
for j ∈ rng
gr_draw_marker(
series,
Expand Down
1 change: 1 addition & 0 deletions PlotsBase/src/Commons/Commons.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ using ..ColorTypes: alpha
using ..RecipesBase
using ..Statistics
using ..NaNMath
using ..Unzip
using ..Printf

const width = Measures.width
Expand Down
2 changes: 2 additions & 0 deletions PlotsBase/src/Commons/attrs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ const _shape_keys = Symbol[
:hline,
:+,
:x,
:uparrow,
:downarrow,
]

const _all_markers = vcat(:none, :auto, _shape_keys) # sort(collect(keys(_shapes))))
Expand Down
2 changes: 2 additions & 0 deletions PlotsBase/src/Shapes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ const _shapes = KW(
:star6 => makestar(6),
:star7 => makestar(7),
:star8 => makestar(8),
:uparrow => Shape([(-1.5,-3), (0,0), (1.5,-3)]),
:downarrow => Shape([(-1.5, 3), (0, 0), (1.5, 3)]),
)

Shape(k::Symbol) = deepcopy(_shapes[k])
Expand Down
5 changes: 5 additions & 0 deletions PlotsBase/src/recipes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,11 @@ end
if plotattributes[:markershape] ≢ :none
primary := false
@series begin
markershape := if plotattributes[:markershape] === :arrow
[isless(yi, 0.0) ? :downarrow : :uparrow for yi in y]
else
plotattributes[:markershape]
end
seriestype := :scatter
x := x
y := y
Expand Down
6 changes: 3 additions & 3 deletions PlotsBase/src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@ function _update_series_attributes!(plotattributes::AKW, plt::Plot, sp::Subplot)

# update markerstrokecolor
plotattributes[:markerstrokecolor] = if plotattributes[:markerstrokecolor] ≡ :match
plot_color(sp[:foreground_color_subplot])
get_series_color(plotattributes[:seriescolor], sp, plotIndex, stype)
elseif plotattributes[:markerstrokecolor] ≡ :auto
get_series_color(plotattributes[:markercolor], sp, plotIndex, stype)
else
get_series_color(plotattributes[:markerstrokecolor], sp, plotIndex, stype)
get_series_color(something(plotattributes[:markerstrokecolor], plotattributes[:seriescolor]), sp, plotIndex, stype)
end

# if marker_z, fill_z or line_z are set, ensure we have a gradient
if plotattributes[:marker_z] ≢ nothing
Commons.ensure_gradient!(plotattributes, :markercolor, :markeralpha)
Expand Down
Loading