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 backend: collision of colorbar_title and colorbar_ticks #4078

Open
jtschneider opened this issue Jan 27, 2022 · 5 comments
Open

[BUG] GR backend: collision of colorbar_title and colorbar_ticks #4078

jtschneider opened this issue Jan 27, 2022 · 5 comments

Comments

@jtschneider
Copy link
Contributor

Details

I have encountered this strange bug when the GR backend is trying to compute the margin of the text between the colorbar ticks and the colorbar title.

Minimal working example:

scatter( rand(10,10),
			zcolor =LinRange(0.05,0.5,10),
			m = (:roma, 0.8, Plots.stroke(1, :green)),
			colorbar_title="Colorbar title",		
		)

image

Obviously, the colorbar title is stuck inside the ticks for the colorbar. This is only remedied by smaller ticks as can be seen e.g. like that:

scatter( rand(10,10),
			zcolor =LinRange(1,10,10),
			m = (:roma, 0.8, Plots.stroke(1, :green)),
			colorbar_title="Colorbar title",		
		)

image

This leads me to believe the GR backend has a fixed distance between colorbartitle and ticks.
I suppose this issue can be fixed easily if one knows where to dig into in order to compute the correct distance from ticks and title..

Backends

This bug occurs on ( insert x below )

Backend yes no untested
gr (default) X
pyplot X
plotlyjs X
pgfplotsx X
unicodeplots X
inspectdr X
gaston X

Versions

Plots.jl version:

(@v1.7) pkg> st Plots
      Status `~/.julia/environments/v1.7/Project.toml`
  [91a5bcdd] Plots v1.25.6

Backend version (]st -m <backend(s)>):

(@v1.7) pkg> st -m GR
      Status `~/.julia/environments/v1.7/Manifest.toml`
  [28b8d3ca] GR v0.63.1

(@v1.7) pkg> st -m PlotlyJS
      Status `~/.julia/environments/v1.7/Manifest.toml`
  [f0f68f2c] PlotlyJS v0.18.8

Output of versioninfo():

julia> versioninfo()
Julia Version 1.7.1
Commit ac5cc99908 (2021-12-22 19:35 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i7-10610U CPU @ 1.80GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, skylake)
@isentropic
Copy link
Member

This does not look like gr

@jtschneider
Copy link
Contributor Author

jtschneider commented Jan 28, 2022

This does not look like gr

Okay, I'm not sure if my semantics is correct. IMHO, I suppose there is an inadequate calculation for the margin between colorbar_title and ticks implemented in Plots.jl (and not in GR.jl or the GR framework itself)
To be precise, I suppose this fixed margin is the culprid (L940:

Plots.jl/src/backends/gr.jl

Lines 939 to 941 in 46e19d9

if sp[:colorbar_title] != ""
rightpad += 4mm
end

Unfortunately, I don't have the time right now to verify

@jtschneider
Copy link
Contributor Author

aha I just saw, my problem is self-made with plot size!
In fact, this is a true minimal working example:

scatter( rand(10,10),
	zcolor = LinRange(0.05,0.5,10),
	size=(320,200),
	m = (:roma, 0.8, Plots.stroke(1, :green)),
	colorbar_title="Colorbar title",
)

yields
image

@drelatgithub
Copy link

I am having the exact same issue here. I might be missing something, but I am wondering why this issue is closed, since the MWE clearly shows that the problem persists. Meanwhile, I cannot find any plot attributes under the "colorbar..." category that can set the padding for the colorbar, so I cannot adjust text locations manually.
Currently, I am using the workaround mentioned here, but in my opinion, this should not be the ultimate solution. Therefore, I might suggest reopening this issue.

@t-bltg
Copy link
Member

t-bltg commented Dec 1, 2022

A partial attempt to fix this for GR has been initiated at #4473, but with some limits.

Should we put the colorbar title to the left of the colorbar instead ?

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

No branches or pull requests

5 participants