From 61d13b9b2d783f2ffa8cebb2518843951c25f20e Mon Sep 17 00:00:00 2001 From: Josef Heinen Date: Thu, 28 Mar 2019 08:39:15 +0100 Subject: [PATCH] gr: improved positioning of Y labels --- src/backends/gr.jl | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/backends/gr.jl b/src/backends/gr.jl index e844c881..be38832f 100644 --- a/src/backends/gr.jl +++ b/src/backends/gr.jl @@ -944,13 +944,20 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas) if yaxis[:guide] != "" gr_set_font(guidefont(yaxis)) GR.setcharup(-1, 0) - x_margin = 0.075 * (viewport_subplot[2] - viewport_subplot[1]) if yaxis[:guide_position] == :right || (yaxis[:guide_position] == :auto && yaxis[:mirror] == true) GR.settextalign(GR.TEXT_HALIGN_CENTER, GR.TEXT_VALIGN_BOTTOM) - gr_text(viewport_plotarea[2] + x_margin, gr_view_ycenter(), yaxis[:guide]) + if viewport_plotarea[1] - viewport_subplot[1] > 0.1 + gr_text(viewport_plotarea[2] + 0.025, gr_view_ycenter(), yaxis[:guide]) + else + gr_text(viewport_subplot[2], gr_view_ycenter(), yaxis[:guide]) + end else GR.settextalign(GR.TEXT_HALIGN_CENTER, GR.TEXT_VALIGN_TOP) - gr_text(viewport_plotarea[1] - x_margin, gr_view_ycenter(), yaxis[:guide]) + if viewport_plotarea[1] - viewport_subplot[1] > 0.1 + gr_text(viewport_plotarea[1] - 0.075, gr_view_ycenter(), yaxis[:guide]) + else + gr_text(viewport_subplot[1], gr_view_ycenter(), yaxis[:guide]) + end end end end