Gaston: support polar
This commit is contained in:
parent
a94c49ab95
commit
52be7387f2
@ -31,7 +31,7 @@ function _before_layout_calcs(plt::Plot{GastonBackend})
|
|||||||
plt.o.layout = gaston_init_subplots(plt, sps)
|
plt.o.layout = gaston_init_subplots(plt, sps)
|
||||||
|
|
||||||
# Then add the series (curves in gaston)
|
# Then add the series (curves in gaston)
|
||||||
for series ∈ plt.series_list
|
for (s, series) ∈ enumerate(plt.series_list)
|
||||||
gaston_add_series(plt, series)
|
gaston_add_series(plt, series)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -90,6 +90,8 @@ function gaston_saveopts(plt::Plot{GastonBackend})
|
|||||||
|
|
||||||
push!(saveopts, "background $(gaston_color(plt.attr[:background_color]))")
|
push!(saveopts, "background $(gaston_color(plt.attr[:background_color]))")
|
||||||
|
|
||||||
|
# push!(saveopts, "title '$(plt.attr[:window_title])'")
|
||||||
|
|
||||||
# Scale all plot elements to match Plots.jl DPI standard
|
# Scale all plot elements to match Plots.jl DPI standard
|
||||||
scaling = plt.attr[:dpi] / Plots.DPI
|
scaling = plt.attr[:dpi] / Plots.DPI
|
||||||
push!(saveopts, "fontscale $scaling lw $scaling dl $scaling ps $scaling")
|
push!(saveopts, "fontscale $scaling lw $scaling dl $scaling ps $scaling")
|
||||||
@ -219,6 +221,9 @@ function gaston_add_series(plt::Plot{GastonBackend}, series::Series)
|
|||||||
if ly == 2 && ly != nc
|
if ly == 2 && ly != nc
|
||||||
y = collect(range(y[1], y[2], length=nc))
|
y = collect(range(y[1], y[2], length=nc))
|
||||||
end
|
end
|
||||||
|
elseif st == :heatmap
|
||||||
|
length(x) == size(z, 2) + 1 && (x = @view x[1:end-1])
|
||||||
|
length(y) == size(z, 1) + 1 && (y = @view y[1:end-1])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for sc ∈ gaston_seriesconf!(sp, series, 1, true)
|
for sc ∈ gaston_seriesconf!(sp, series, 1, true)
|
||||||
@ -315,6 +320,8 @@ function gaston_parse_axes_args(
|
|||||||
# axesconf = String["set margins 2, 2, 2, 2"] # left, right, bottom, top
|
# axesconf = String["set margins 2, 2, 2, 2"] # left, right, bottom, top
|
||||||
axesconf = String[]
|
axesconf = String[]
|
||||||
|
|
||||||
|
polar = ispolar(sp) && dims == 2 # cannot splot in polar coordinates
|
||||||
|
|
||||||
for letter ∈ (:x, :y, :z)
|
for letter ∈ (:x, :y, :z)
|
||||||
(letter == :z && dims == 2) && continue
|
(letter == :z && dims == 2) && continue
|
||||||
axis = sp.attr[Symbol(letter, :axis)]
|
axis = sp.attr[Symbol(letter, :axis)]
|
||||||
@ -322,9 +329,6 @@ function gaston_parse_axes_args(
|
|||||||
push!(axesconf, "set $(letter)label '$(axis[:guide])' $(gaston_font(guidefont(axis)))")
|
push!(axesconf, "set $(letter)label '$(axis[:guide])' $(gaston_font(guidefont(axis)))")
|
||||||
mirror = axis[:mirror] ? "mirror" : "nomirror"
|
mirror = axis[:mirror] ? "mirror" : "nomirror"
|
||||||
|
|
||||||
# handle ticks
|
|
||||||
push!(axesconf, "set $(letter)tics $(mirror) $(axis[:tick_direction]) $(gaston_font(tickfont(axis)))")
|
|
||||||
|
|
||||||
if axis[:scale] == :identity
|
if axis[:scale] == :identity
|
||||||
logscale, base = "nologscale", ""
|
logscale, base = "nologscale", ""
|
||||||
elseif axis[:scale] == :log10
|
elseif axis[:scale] == :log10
|
||||||
@ -336,27 +340,34 @@ function gaston_parse_axes_args(
|
|||||||
end
|
end
|
||||||
push!(axesconf, "set $logscale $letter $base")
|
push!(axesconf, "set $logscale $letter $base")
|
||||||
|
|
||||||
# major tick locations
|
# handle ticks
|
||||||
if axis[:ticks] != :native
|
if polar
|
||||||
if axis[:flip]
|
push!(axesconf, "set size square\nunset $(letter)tics")
|
||||||
hi, lo = axis_limits(sp, letter)
|
else
|
||||||
else
|
push!(axesconf, "set $(letter)tics $(mirror) $(axis[:tick_direction]) $(gaston_font(tickfont(axis)))")
|
||||||
lo, hi = axis_limits(sp, letter)
|
|
||||||
end
|
|
||||||
push!(axesconf, "set $(letter)range [$lo:$hi]")
|
|
||||||
|
|
||||||
ticks = get_ticks(sp, axis)
|
# major tick locations
|
||||||
gaston_set_ticks!(axesconf, ticks, letter, "", "")
|
if axis[:ticks] != :native
|
||||||
|
if axis[:flip]
|
||||||
|
hi, lo = axis_limits(sp, letter)
|
||||||
|
else
|
||||||
|
lo, hi = axis_limits(sp, letter)
|
||||||
|
end
|
||||||
|
push!(axesconf, "set $(letter)range [$lo:$hi]")
|
||||||
|
|
||||||
if axis[:minorticks] != :native
|
ticks = get_ticks(sp, axis)
|
||||||
minor_ticks = get_minor_ticks(sp, axis, ticks)
|
gaston_set_ticks!(axesconf, ticks, letter, "", "")
|
||||||
gaston_set_ticks!(axesconf, minor_ticks, letter, "m", "add")
|
|
||||||
|
if axis[:minorticks] != :native
|
||||||
|
minor_ticks = get_minor_ticks(sp, axis, ticks)
|
||||||
|
gaston_set_ticks!(axesconf, minor_ticks, letter, "m", "add")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if axis[:grid]
|
if axis[:grid]
|
||||||
push!(axesconf, "set grid $(letter)tics")
|
push!(axesconf, "set grid " * (polar ? "polar" : "$(letter)tics"))
|
||||||
axis[:minorgrid] && push!(axesconf, "set grid m$(letter)tics")
|
axis[:minorgrid] && push!(axesconf, "set grid " * (polar ? "polar" : "m$(letter)tics"))
|
||||||
end
|
end
|
||||||
|
|
||||||
ratio = get_aspect_ratio(sp)
|
ratio = get_aspect_ratio(sp)
|
||||||
@ -375,6 +386,23 @@ function gaston_parse_axes_args(
|
|||||||
push!(axesconf, "set title '$(sp[:title])' $(gaston_font(titlefont(sp)))")
|
push!(axesconf, "set title '$(sp[:title])' $(gaston_font(titlefont(sp)))")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if polar
|
||||||
|
push!(axesconf, "unset border\nset polar\nset border polar")
|
||||||
|
tmin, tmax = axis_limits(sp, :x, false, false)
|
||||||
|
rmin, rmax = axis_limits(sp, :y, false, false)
|
||||||
|
rticks = get_ticks(sp, :y)
|
||||||
|
if (ttype = ticksType(rticks)) == :ticks
|
||||||
|
gaston_ticks = String[string(t) for (t, l) ∈ zip(rticks...)]
|
||||||
|
elseif ttype == :ticks_and_labels
|
||||||
|
gaston_ticks = String["'$l' $t" for (t, l) ∈ zip(rticks...)]
|
||||||
|
end
|
||||||
|
push!(axesconf, "set rtics ( " * join(gaston_ticks, ", ") * " ) $(gaston_font(tickfont(sp.attr[:yaxis])))")
|
||||||
|
push!(axesconf, "set trange [$(min(0, tmin)):$(max(2π, tmax))]")
|
||||||
|
push!(axesconf, "set rrange [$rmin:$rmax]")
|
||||||
|
push!(axesconf, "set ttics 0,30 format \"%g\".GPVAL_DEGREE_SIGN $(gaston_font(tickfont(sp.attr[:xaxis])))")
|
||||||
|
push!(axesconf, "set mttics 3")
|
||||||
|
end
|
||||||
|
|
||||||
return join(axesconf, "\n")
|
return join(axesconf, "\n")
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -385,9 +413,8 @@ function gaston_set_ticks!(axesconf, ticks, letter, maj_min, add)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
ttype = ticksType(ticks)
|
|
||||||
gaston_ticks = String[]
|
gaston_ticks = String[]
|
||||||
if ttype == :ticks
|
if (ttype = ticksType(ticks)) == :ticks
|
||||||
tick_locs = @view ticks[:]
|
tick_locs = @view ticks[:]
|
||||||
for i ∈ eachindex(tick_locs)
|
for i ∈ eachindex(tick_locs)
|
||||||
tick = if maj_min == "m"
|
tick = if maj_min == "m"
|
||||||
@ -487,6 +514,7 @@ function gaston_marker(marker, alpha)
|
|||||||
marker == :dtriangle && return filled ? 11 : 10
|
marker == :dtriangle && return filled ? 11 : 10
|
||||||
marker == :diamond && return filled ? 13 : 12
|
marker == :diamond && return filled ? 13 : 12
|
||||||
marker == :pentagon && return filled ? 15 : 14
|
marker == :pentagon && return filled ? 15 : 14
|
||||||
|
marker ∈ (:vline, :hline) && return marker
|
||||||
|
|
||||||
@warn "Gaston: unsupported marker $marker"
|
@warn "Gaston: unsupported marker $marker"
|
||||||
return 1
|
return 1
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user