From 87b5b1df112a3fb140917035a1f3af85f59ec932 Mon Sep 17 00:00:00 2001 From: zhanibek Date: Thu, 10 Dec 2020 17:01:55 +0900 Subject: [PATCH] gnuplot version 0.1 --- src/backends/gaston.jl | 44 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/src/backends/gaston.jl b/src/backends/gaston.jl index 4ee87cb0..4b8cc384 100644 --- a/src/backends/gaston.jl +++ b/src/backends/gaston.jl @@ -207,10 +207,15 @@ function gaston_parse_axes_args(plt::Plot{GastonBackend}, sp::Subplot{GastonBack ticks = get_ticks(sp, axis_attr) gaston_set_ticks!(axesconf, ticks, letter) end - - - # TODO logscale, explicit tick location, range, + # set title {""} {offset } {font "{,}"}{{textcolor | tc} { | default}} {{no}enhanced}1 end + gaston_set_legend!(axesconf, sp) # Set legend params + + if sp[:title] != nothing + push!(axesconf, """set title '$(sp[:title])' """) + push!(axesconf, """set title font '$(sp[:titlefontfamily]), $(sp[:titlefontsize])' """) + end + return join(axesconf, "\n") end @@ -254,6 +259,39 @@ function gaston_set_ticks!(axesconf, ticks, letter) end end +function gaston_set_legend!(axesconf, sp) + leg = sp[:legend] + if !(sp[:legend] in(:none, :inline)) + if leg == :best + leg = :topright + end + + if occursin("outer", string(leg)) + push!(axesconf, "set key outside") + else + push!(axesconf, "set key inside") + end + positions = ["top", "bottom", "left", "right"] + for position in positions + if occursin(position, string(leg)) + push!(axesconf, "set key $position") + end + end + if sp[:legendtitle] != nothing + push!(axesconf, "set key title '$(sp[:legendtitle])'") + end + push!(axesconf, "set key box linewidth 1") + push!(axesconf, "set key opaque") + + push!(axesconf, "set border back") + push!(axesconf, """set key font "$(sp[:legendfontfamily]), $(sp[:legendfontsize])" """) + else + push!(axesconf, "set key off") + + end + +end + function gaston_marker(marker) marker == :none && return -1 marker == :circle && return 7