Skip to content

Commit 5fb6435

Browse files
committed
UnicodePlots: Ensure integer resolution and divide size by 10
1 parent 133edb5 commit 5fb6435

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

ext/GridVisualizeUnicodePlotsExt.jl

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ function gridplot!(ctx, TP::Type{UnicodePlotsType}, ::Type{Val{2}}, grid)
6464
color = ctx[:color]
6565
end
6666

67-
# determine resolution
68-
resolution = @. Int(round(ctx[:size]))
67+
# determine resolution (divided by 10, to reduce pixel count in the terminal)
68+
resolution = ctx[:size] ./ 10
6969
legend_space = 4
7070
aspect = ctx[:aspect] * resolution[1] / (resolution[1] + legend_space)
7171

@@ -80,6 +80,9 @@ function gridplot!(ctx, TP::Type{UnicodePlotsType}, ::Type{Val{2}}, grid)
8080
end
8181
end
8282

83+
# we need an integer resolution
84+
resolution = @. Int(round(resolution))
85+
8386
# create UnicodePlots.Canvas
8487
padding = 0.1 * max(ex[2] - ex[1], ey[2] - ey[1])
8588
ex = (ex[1] - 2 * padding, ex[2] + 0.5 * padding)
@@ -212,8 +215,8 @@ function gridplot!(ctx, TP::Type{UnicodePlotsType}, ::Type{Val{1}}, grid)
212215
color = ctx[:color]
213216
end
214217

215-
# determine resolution
216-
resolution = (Int(round(ctx[:size][1])), 5)
218+
# determine resolution (divided by 10, to reduce pixel count in the terminal)
219+
resolution = (Int(round(ctx[:size][1] / 10)), 5)
217220

218221
# create UnicodePlots.Canvas
219222
legend_space = 5
@@ -303,7 +306,7 @@ function scalarplot!(
303306
)
304307

305308
nfuncs = length(funcs)
306-
resolution = @. Int(round(ctx[:size]))
309+
resolution = @. Int(round(ctx[:size] ./ 10)) # reduce pixel count in the terminal
307310
ylim = ctx[:limits]
308311

309312
if ylim[1] > ylim[2]
@@ -338,7 +341,7 @@ function scalarplot!(
338341
)
339342

340343
func = funcs[1]
341-
resolution = @. Int(round(ctx[:size]))
344+
resolution = @. Int(round(ctx[:size] ./ 10)) # reduce pixel count in the terminal
342345
ylim = ctx[:limits]
343346
colormap = ctx[:colormap]
344347

0 commit comments

Comments
 (0)