Skip to content

Commit

Permalink
Accept ranges in yticks, xticks
Browse files Browse the repository at this point in the history
  • Loading branch information
cmcaine committed Jul 2, 2019
1 parent d58343a commit ba0374c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/guide.jl
Original file line number Diff line number Diff line change
Expand Up @@ -556,14 +556,15 @@ struct XTicks <: Gadfly.GuideElement
end
end

XTicks(label, ticks::AbstractRange, orientation) = XTicks(label, collect(ticks), orientation)
XTicks(; label=true, ticks=:auto, orientation=:auto) = XTicks(label, ticks, orientation)

"""
Guide.xticks[(; label=true, ticks=:auto, orientation=:auto)]
Guide.xticks(label, ticks, orientation)
Formats the tick marks and labels for the x-axis. `label` toggles the label
visibility. `ticks` can also be an array of locations, or `nothing`.
visibility. `ticks` can also be an array of locations, a range, or `nothing`.
`orientation` can also be `:horizontal` or `:vertical`.
"""
const xticks = XTicks
Expand Down Expand Up @@ -727,14 +728,15 @@ struct YTicks <: Gadfly.GuideElement
end
end

YTicks(label, ticks::AbstractRange, orientation) = YTicks(label, collect(ticks), orientation)
YTicks(; label=true, ticks=:auto, orientation=:horizontal) = YTicks(label, ticks, orientation)

"""
Guide.yticks[(; label=true, ticks=:auto, orientation=:horizontal)]
Guide.yticks(ticks, label, orientation)
Formats the tick marks and labels for the y-axis. `label` toggles the label
visibility. `ticks` can also be an array of locations, or `nothing`.
visibility. `ticks` can also be an array of locations, a range, or `nothing`.
`orientation` can also be `:auto` or `:vertical`.
"""
const yticks = YTicks
Expand Down
8 changes: 8 additions & 0 deletions test/testscripts/explicit_xy_ticks_range.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using Gadfly

set_default_plot_size(6inch, 3inch)

plot(x=[0.236033, 0.346517, 0.312707, 0.00790928, 0.488613, 0.210968, 0.951916, 0.999905, 0.251662, 0.986666],
y=[0.555751, 0.437108, 0.424718, 0.773223, 0.28119, 0.209472, 0.251379, 0.0203749, 0.287702, 0.859512],
Guide.xticks(ticks=0:1),
Guide.yticks(ticks=0.4:0.1:0.6))

0 comments on commit ba0374c

Please sign in to comment.