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

Treat major and minor ticks differently (in GR, for now) #1788

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions src/arg_desc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ const _arg_desc = KW(
:tickfontvalign => "Symbol. Font vertical alignment of tick labels: :vcenter, :top, :bottom or :center",
:tickfontrotation => "Real. Font rotation of tick labels",
:tickfontcolor => "Color Type. Font color of tick labels",
:foreground_color_tick => "Color Type. Color of major ticks.",
:foreground_color_minortick => "Color Type. Color of minor ticks.",
:guidefontfamily => "String or Symbol. Font family of axes guides.",
:guidefontsize => "Integer. Font pointsize of axes guides.",
:guidefonthalign => "Symbol. Font horizontal alignment of axes guides: :hcenter, :left, :right or :center",
Expand Down
6 changes: 6 additions & 0 deletions src/args.jl
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,8 @@ const _axis_defaults = KW(
:tickfontvalign => :vcenter,
:tickfontrotation => 0.0,
:tickfontcolor => :match,
:foreground_color_tick => :match,
:foreground_color_minortick => :match,
:guidefontfamily => :match,
:guidefontsize => 11,
:guidefonthalign => :hcenter,
Expand Down Expand Up @@ -1283,6 +1285,8 @@ const _match_map2 = KW(
:fontfamily_subplot => :fontfamily,
:tickfontfamily => :fontfamily_subplot,
:guidefontfamily => :fontfamily_subplot,
:foreground_color_tick => :foreground_color_subplot,
:foreground_color_minortick => :foreground_color_subplot
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add these to _match_map instead and let them default to :foreground_color_axis (which then defaults to :foreground_color_subplot). Then you should be able to have different tick colors for different axis.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey @greimel would you mind doing this minor change so we can get this merged? Thanks!

)

# properly retrieve from plt.attr, passing `:match` to the correct key
Expand Down Expand Up @@ -1466,6 +1470,8 @@ function _update_axis_colors(axis::Axis)
color_or_nothing!(axis.plotattributes, :foreground_color_text)
color_or_nothing!(axis.plotattributes, :foreground_color_grid)
color_or_nothing!(axis.plotattributes, :foreground_color_minor_grid)
color_or_nothing!(axis.plotattributes, :foreground_color_tick)
color_or_nothing!(axis.plotattributes, :foreground_color_minortick)
return
end

Expand Down
8 changes: 5 additions & 3 deletions src/axes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,8 @@ function axis_drawing_info(sp::Subplot)
ytick_segs = Segments(2)
xgrid_segs = Segments(2)
ygrid_segs = Segments(2)
xminortick_segs = Segments(2)
yminortick_segs = Segments(2)
xminorgrid_segs = Segments(2)
yminorgrid_segs = Segments(2)
xborder_segs = Segments(2)
Expand Down Expand Up @@ -657,7 +659,7 @@ function axis_drawing_info(sp::Subplot)
else
xor(xaxis[:mirror], yaxis[:flip]) ? (ymax, t2) : (ymin, t1)
end
push!(xtick_segs, (xminortick, tick_start), (xminortick, tick_stop)) # bottom tick
push!(xminortick_segs, (xminortick, tick_start), (xminortick, tick_stop)) # bottom tick
end
# sp[:draw_axes_border] && push!(xaxis_segs, (xtick, ymax), (xtick, t2)) # top tick
xaxis[:minorgrid] && push!(xminorgrid_segs, (xminortick, ymin), (xminortick, ymax)) # vertical grid
Expand Down Expand Up @@ -718,13 +720,13 @@ function axis_drawing_info(sp::Subplot)
else
xor(yaxis[:mirror], xaxis[:flip]) ? (xmax, t2) : (xmin, t1)
end
push!(ytick_segs, (tick_start, ytick), (tick_stop, ytick)) # left tick
push!(yminortick_segs, (tick_start, ytick), (tick_stop, ytick)) # left tick
end
# sp[:draw_axes_border] && push!(yaxis_segs, (xmax, ytick), (t2, ytick)) # right tick
yaxis[:minorgrid] && push!(yminorgrid_segs, (xmin, ytick), (xmax, ytick)) # horizontal grid
end
end
end

xticks, yticks, xaxis_segs, yaxis_segs, xtick_segs, ytick_segs, xgrid_segs, ygrid_segs, xminorgrid_segs, yminorgrid_segs, xborder_segs, yborder_segs
xticks, yticks, xaxis_segs, yaxis_segs, xtick_segs, ytick_segs, xgrid_segs, ygrid_segs, xminorgrid_segs, yminorgrid_segs, xborder_segs, yborder_segs, xminortick_segs, yminortick_segs
end
2 changes: 2 additions & 0 deletions src/backends.jl
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,11 @@ const _gr_attr = merge_with_base_supported([
:legendfontrotation, :legendfontcolor,
:tickfontfamily, :tickfontsize, :tickfonthalign, :tickfontvalign,
:tickfontrotation, :tickfontcolor,
:foreground_color_tick, :foreground_color_minortick,
:guidefontfamily, :guidefontsize, :guidefonthalign, :guidefontvalign,
:guidefontrotation, :guidefontcolor,
:grid, :gridalpha, :gridstyle, :gridlinewidth,
:minorgridalpha, :minorgridlinewidth,
:legend, :legendtitle, :colorbar, :colorbar_title,
:fill_z, :line_z, :marker_z, :levels,
:ribbon, :quiver,
Expand Down
33 changes: 28 additions & 5 deletions src/backends/gr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
GR.setwindow(xmin, xmax, ymin, ymax)
end

xticks, yticks, xspine_segs, yspine_segs, xtick_segs, ytick_segs, xgrid_segs, ygrid_segs, xminorgrid_segs, yminorgrid_segs, xborder_segs, yborder_segs = axis_drawing_info(sp)
xticks, yticks, xspine_segs, yspine_segs, xtick_segs, ytick_segs, xgrid_segs, ygrid_segs, xminorgrid_segs, yminorgrid_segs, xborder_segs, yborder_segs, xminortick_segs, yminortick_segs = axis_drawing_info(sp)
# @show xticks yticks #spine_segs grid_segs

# draw the grid lines
Expand Down Expand Up @@ -810,26 +810,49 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
# axis ticks
if xaxis[:showaxis]
if sp[:framestyle] in (:zerolines, :grid)
gr_set_line(1, :solid, xaxis[:foreground_color_grid])
gr_set_line(1, :solid, xaxis[:foreground_color_tick])
gr_set_transparency(xaxis[:gridalpha])
else
gr_set_line(1, :solid, xaxis[:foreground_color_axis])
gr_set_line(1, :solid, xaxis[:foreground_color_tick])
end
GR.setclip(0)
gr_polyline(coords(xtick_segs)...)
end
if yaxis[:showaxis]
if sp[:framestyle] in (:zerolines, :grid)
gr_set_line(1, :solid, yaxis[:foreground_color_grid])
gr_set_line(1, :solid, yaxis[:foreground_color_tick])
gr_set_transparency(yaxis[:gridalpha])
else
gr_set_line(1, :solid, yaxis[:foreground_color_axis])
gr_set_line(1, :solid, yaxis[:foreground_color_tick])
end
GR.setclip(0)
gr_polyline(coords(ytick_segs)...)
end
GR.setclip(1)

# axis minor ticks
if xaxis[:showaxis]
if sp[:framestyle] in (:zerolines, :grid)
gr_set_line(1, :solid, xaxis[:foreground_color_minortick])
gr_set_transparency(xaxis[:minorgridalpha])
else
gr_set_line(1, :solid, xaxis[:foreground_color_minortick])
end
GR.setclip(0)
gr_polyline(coords(xminortick_segs)...)
end
if yaxis[:showaxis]
if sp[:framestyle] in (:zerolines, :grid)
gr_set_line(1, :solid, yaxis[:foreground_color_minortick])
gr_set_transparency(yaxis[:minorgridalpha])
else
gr_set_line(1, :solid, yaxis[:foreground_color_minortick])
end
GR.setclip(0)
gr_polyline(coords(yminortick_segs)...)
end
GR.setclip(1)

# tick marks
if !(xticks in (:none, nothing, false)) && xaxis[:showaxis]
# x labels
Expand Down