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

Proposed fix for Latex sub/super-scripts in legends #3598

Merged
merged 2 commits into from Jul 4, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/backends/gr.jl
Expand Up @@ -1162,25 +1162,25 @@ function gr_legend_pos(theta::Real, leg, viewport_plotarea; axisclearance=nothin
end

function gr_get_legend_geometry(viewport_plotarea, sp)
legendn = 0
legendw = 0
legendn = legendw = dy = 0
if sp[:legend] != :none
GR.savestate()
GR.selntran(0)
GR.setscale(0)
if sp[:legendtitle] !== nothing
gr_set_font(legendtitlefont(sp), sp)
legendn += 1
tbx, tby = gr_inqtext(0, 0, string(sp[:legendtitle]))
legendw = tbx[3] - tbx[1]
legendn += 1
dy = tby[3] - tby[1]
end
gr_set_font(legendfont(sp), sp)
for series in series_list(sp)
should_add_to_legend(series) || continue
legendn += 1
lab = series[:label]
tbx, tby = gr_inqtext(0, 0, string(lab))
tbx, tby = gr_inqtext(0, 0, string(series[:label]))
legendw = max(legendw, tbx[3] - tbx[1]) # Holds text width right now
dy = max(dy, tby[3] - tby[1])
end

GR.setscale(1)
Expand All @@ -1197,7 +1197,8 @@ function gr_get_legend_geometry(viewport_plotarea, sp)
x_legend_offset = (viewport_plotarea[2] - viewport_plotarea[1]) / 30
y_legend_offset = (viewport_plotarea[4] - viewport_plotarea[3]) / 30

dy = gr_point_mult(sp) * sp[:legendfontsize] * 1.75
dy *= get(sp[:extra_kwargs], :legend_hfactor, 1)

legendh = dy * legendn

return (
Expand Down