Skip to content

Commit 13db741

Browse files
authored
add xlabel, ylabel, title to 2D gridplots (#112)
Co-authored-by: Marieke Osewold <osewold@wias-berlin.de>
1 parent a97adce commit 13db741

5 files changed

Lines changed: 16 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## [1.16.3] - 2026-01-07
4+
- Add `title`, `xlabel`, and `ylabel` to 1D and 2D `gridplot!` with `GLMakie`
5+
- Add `title`, `xlabel`, and `ylabel` to 1D and 2D `gridplot!` with `Py[thon]Plot`
6+
37
## [1.16.2] - 2025-12-04
48
- `leglocs[:cc]`: correct "center center" to "center"
59

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "GridVisualize"
22
uuid = "5eed8a63-0fb0-45eb-886d-8d5a387d12b8"
33
authors = ["Juergen Fuhrmann <juergen.fuhrmann@wias-berlin.de>", "Patrick Jaap <patrick.jaap@wias-berlin.de>"]
4-
version = "1.16.2"
4+
version = "1.16.3"
55

66
[deps]
77
ColorSchemes = "35d6a980-a343-548e-a6ea-1d62b119f2f4"

ext/GridVisualizeMakieExt.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ function scenecorners1d(grid, gridscale)
275275
return [Point2f(xmin * gridscale, -5 * h), Point2f(xmax * gridscale, 5 * h)]
276276
end
277277

278+
# 1D version
278279
function gridplot!(ctx, TP::Type{MakieType}, ::Type{Val{1}}, grid)
279280
XMakie = ctx[:Plotter]
280281
nregions = num_cellregions(grid)
@@ -286,6 +287,7 @@ function gridplot!(ctx, TP::Type{MakieType}, ::Type{Val{1}}, grid)
286287
yticklabelsvisible = false,
287288
yticksvisible = false,
288289
title = ctx[:title],
290+
xlabel = ctx[:xlabel],
289291
scenekwargs(ctx)...,
290292
)
291293

@@ -619,6 +621,8 @@ function gridplot!(ctx, TP::Type{MakieType}, ::Type{Val{2}}, grid)
619621
ctx[:scene] = XMakie.Axis(
620622
ctx[:figure];
621623
title = ctx[:title],
624+
xlabel = ctx[:xlabel],
625+
ylabel = ctx[:ylabel],
622626
aspect = aspect,
623627
autolimitaspect = autolimitaspect,
624628
scenekwargs(ctx)...,

src/dispatch.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ Depending on the `layout` keyword argument, a 2D grid of subplots is created.
221221
Further `...plot!` commands then plot into one of these subplots:
222222
223223
```julia
224-
vis=GridVisualizer(Plotter=PyPlot, layout=(2,2)
224+
vis=GridVisualizer(Plotter=PyPlot, layout=(2,2))
225225
...plot!(vis[1,2], ...)
226226
```
227227

src/pycommon.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ function gridplot!(ctx, TP::Type{T}, ::Type{Val{1}}, grid) where {T <: AbstractP
149149
ax.grid(true)
150150
ax.get_yaxis().set_ticks(Float64[])
151151
ax.set_ylim(-5 * h, xmax - xmin)
152+
ax.set_title(ctx[:title])
153+
ax.set_xlabel(ctx[:xlabel])
154+
152155
cmap = region_cmap(max(ncellregions, 5))
153156
gridscale = ctx[:gridscale]
154157

@@ -212,6 +215,9 @@ function gridplot!(ctx, TP::Type{T}, ::Type{Val{2}}, grid) where {T <: AbstractP
212215
end
213216
end
214217
ax = ctx[:ax]
218+
ax.set_title(ctx[:title])
219+
ax.set_xlabel(ctx[:xlabel])
220+
ax.set_ylabel(ctx[:ylabel])
215221
fig = ctx[:figure]
216222
cellregions = cellcolors(grid, ctx[:cellcoloring])
217223
ncellregions = num_cellcolors(grid, ctx[:cellcoloring])

0 commit comments

Comments
 (0)