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

Improve bar_labels: LaTeXStrings and fontsize #2501

Merged
merged 5 commits into from
Jul 22, 2023

Conversation

greimel
Copy link
Contributor

@greimel greimel commented Dec 13, 2022

Unfortunately this doesn't work yet because

text([1], [1]; text = [L"a"], align = Vec2f[[0, 0]])

doesn't work.

Here's an example

barplot([1, 2], [0.5, 0.2], bar_labels = [L"a", "b"])

fig

@greimel greimel marked this pull request as draft December 13, 2022 18:22
src/basic_recipes/barplot.jl Show resolved Hide resolved
src/basic_recipes/barplot.jl Outdated Show resolved Hide resolved
@greimel
Copy link
Contributor Author

greimel commented Dec 13, 2022

That's how it looks now

fig2

let
	fig = Figure()
	lab1 = L"a - b"
	lab2 = L"\frac{a}{b} - \sqrt{b}"

	barplot(fig[1,1], [1, 2], [0.5, 0.2], bar_labels = [lab1, lab1], flip_labels_at = 0.3, direction=:x)
	barplot(fig[1,2], [1, 2], [0.5, 0.2], bar_labels = [lab1, lab1], flip_labels_at = 0.3)
	barplot(fig[2,1], [1, 2], [0.5, 0.2], bar_labels = [lab2, lab2], flip_labels_at = 0.3, direction=:x)
	barplot(fig[2,2], [1, 2], [0.5, 0.2], bar_labels = [lab2, lab2], flip_labels_at = 0.3)

	text(fig[1,3], [1], [1]; text = [lab2], align = [(-1, 1)])
	fig
	save("/tmp/fig.png", fig); run(`open /tmp/fig.png`)
end
  • Do you have an idea, how the hlines in fraction and square root can be fixed? (probably also cc @Kolaru)
  • What do you think about factoring out get_xshift and get_yshift? I've just seen that this is used in layouting.jl as well. So one could share this functionality even more widely.

@Kolaru
Copy link
Contributor

Kolaru commented Dec 15, 2022

  • Do you have an idea, how the hlines in fraction and square root can be fixed? (probably also cc @Kolaru)

Somehow Makie is rendering the line at the incorrect position. I spent some time on it but couldn't quite understand this drawing pipeline and were the problem could come from. Due to how it looks, I suspect it has something to do with scaling of the lines at some point.

@greimel
Copy link
Contributor Author

greimel commented Dec 15, 2022

I narrowed down the offender: it's the offset keyword [EDITED, thanks @jkrumbiegel]

Screen.Recording.2022-12-15.at.14.32.42.mov

@jkrumbiegel
Copy link
Member

jkrumbiegel commented Dec 15, 2022

I narrowed down the offender: it's the align keyword
Screen.Recording.2022-12-15.at.14.32.42.mov

Aren't you demonstrating in your video that it's offset and not align? :) I assume the code that updates the linesegments is not hooked up to that observable. It will probably correct with a jump when you change for example the align after you've introduced a gap via offset.

@greimel
Copy link
Contributor Author

greimel commented Dec 15, 2022

No, it doesn't. I am not using observables there. The plot is completely redrawn at each slider change.

Screen.Recording.2022-12-15.at.14.42.34.mov

@jkrumbiegel
Copy link
Member

jkrumbiegel commented Dec 15, 2022

Ok then offset is just completely ignored for linesegments calculation :)

Yeah it's missing in this argument list: https://github.com/MakieOrg/Makie.jl/blob/master/src/basic_recipes/text.jl#L87

@greimel
Copy link
Contributor Author

greimel commented Dec 15, 2022

Thanks for the hint!

Let's see if I manage to digest all these abbreviations.

@greimel
Copy link
Contributor Author

greimel commented Dec 15, 2022

Would you mind if I leave this bug for someone else to fix? I think this PR is already a strict improvement, and the ignored offset is kind of orthogonal.

@jkrumbiegel
Copy link
Member

Sure!

@greimel greimel marked this pull request as ready for review December 15, 2022 14:03
@greimel
Copy link
Contributor Author

greimel commented Dec 15, 2022

Does this need a reference test?

@greimel
Copy link
Contributor Author

greimel commented Jan 10, 2023

friendly bump - is there something I can do do help getting this merged?

@SimonDanisch
Copy link
Member

Ah, yeah a reference test would be nice if it's not too much work ;)
Just add it too the bottom here: https://github.com/MakieOrg/Makie.jl/blob/master/ReferenceTests/src/tests/primitives.jl

alignment


use `align` keyword again


use `get_xshift` once more


fix
@SimonDanisch
Copy link
Member

Thank you!

@SimonDanisch SimonDanisch merged commit acf64cf into MakieOrg:master Jul 22, 2023
13 checks passed
@greimel greimel deleted the bar_labels branch July 24, 2023 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants