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

[BUG] GR guidefontvalign, guidefonthalign do not align the labels #3376

Closed
mmikhasenko opened this issue Mar 25, 2021 · 3 comments
Closed

[BUG] GR guidefontvalign, guidefonthalign do not align the labels #3376

mmikhasenko opened this issue Mar 25, 2021 · 3 comments
Labels

Comments

@mmikhasenko
Copy link
Contributor

plot(rand(10), xlab="x (Unt)", ylab="y (Unt)",
    guidefontvalign=:top, guidefonthalign=:right)

image

The issues seems to be in gr_label_axis function that

function gr_label_axis(sp, letter, viewport_plotarea)

Versions:

[28b8d3ca] GR v0.55.0 `https://github.com/jheinen/GR.jl.git#master`
[d2c73de3] GR_jll v0.53.0+0
>>>>>
Julia Version 1.5.0
Commit 96786e22cc (2020-08-01 23:44 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-9.0.1 (ORCJIT, skylake)
Environment:
  JULIA_EDITOR = "Microsoft VS Code\Code.exe"
  JULIA_NUM_THREADS = 1
@mmikhasenko
Copy link
Contributor Author

A dirty fix

gr_text(gr_view_xright(viewport_plotarea), viewport_plotarea[3] - h, xaxis[:guide])
gr_text(viewport_plotarea[1] - w, gr_view_yright(viewport_plotarea), yaxis[:guide])

with

gr_view_xright(viewport_plotarea) = viewport_plotarea[1] + 0.9 * (viewport_plotarea[2] - viewport_plotarea[1])
gr_view_yright(viewport_plotarea) = viewport_plotarea[3] + 0.9 * (viewport_plotarea[4] - viewport_plotarea[3])

@mmikhasenko
Copy link
Contributor Author

A bit more accurate

gr_view_xposition(viewport_plotarea, position) = viewport_plotarea[1] + position * (viewport_plotarea[2] - viewport_plotarea[1])
gr_view_yposition(viewport_plotarea, position) = viewport_plotarea[3] + position * (viewport_plotarea[4] - viewport_plotarea[3])

function position(symb)
    if symb == :top || symb == :right
        return 0.95
    elseif symb == :left || symb == :bottom
        return 0.05
    end
    return 0.5
end

function alignment(symb)
    if symb == :top || symb == :right
        return GR.TEXT_HALIGN_RIGHT
    elseif symb == :left || symb == :bottom
        return GR.TEXT_HALIGN_LEFT
    end
    return GR.TEXT_HALIGN_CENTER
end

@mmikhasenko
Copy link
Contributor Author

fixed for gr() by #3377 #3390

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant