Skip to content
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

Use label formatter in barplot. #3718

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/basic_recipes/barplot.jl
@@ -1,6 +1,6 @@
function bar_label_formatter(value::Number)
return string(round(value; digits=3))
end
bar_label_formatter(value::Number) = string(round(value; digits=3))
bar_label_formatter(label::String) = label
bar_label_formatter(label::LaTeXString) = label

Check warning on line 3 in src/basic_recipes/barplot.jl

View check run for this annotation

Codecov / codecov/patch

src/basic_recipes/barplot.jl#L3

Added line #L3 was not covered by tests

"""
bar_default_fillto(tf, ys, offset)::(ys, offset)
Expand Down Expand Up @@ -226,7 +226,7 @@
attributes = text_attributes(ypositions, in_y_direction, flip_labels_at, color_over_background,
color_over_bar, label_offset, label_rotation, label_align)
label_pos = map(xpositions, ypositions, bar_labels) do x, y, l
return (string(l), in_y_direction ? Point2f(x, y) : Point2f(y, x))
return (label_formatter(l), in_y_direction ? Point2f(x, y) : Point2f(y, x))
end
return (label_pos, attributes...)
else
Expand Down