Skip to content

Commit 941ea1d

Browse files
mariekeoswpjaap
authored andcommitted
Reduce duplication in colorbar logic
1 parent b5a376b commit 941ea1d

3 files changed

Lines changed: 7 additions & 29 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Changelog
22

3-
## [1.18.1] - 2026-04-21
3+
## [1.18.2] - 2026-04-21
44
- Add colorbar for cell regions in 2D `gridplot!` with `Py[thon]Plot`
55

66
## [1.18.0] - 2026-04-15

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.18.1"
4+
version = "1.18.2"
55

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

src/pycommon.jl

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -274,41 +274,19 @@ function gridplot!(ctx, TP::Type{T}, ::Type{Val{2}}, grid) where {T <: AbstractP
274274
)
275275

276276
if ctx[:show_colorbar]
277-
if ctx[:colorbar] == :horizontal
278-
277+
if ctx[:colorbar] in (:horizontal, :vertical)
279278
fig.colorbar(
280279
bcdata;
281280
ax = ax,
282-
ticks = collect(1:length(bcmap)),
283-
orientation = "horizontal",
281+
ticks = 1:length(bcmap),
282+
orientation = "$(ctx[:colorbar])",
284283
label = "boundary regions"
285284
)
286-
287-
fig.colorbar(
288-
cdata;
289-
ax = ax,
290-
ticks = collect(1:length(cmap)),
291-
orientation = "horizontal",
292-
label = "cell regions"
293-
)
294-
295-
end
296-
297-
if ctx[:colorbar] == :vertical
298-
299-
fig.colorbar(
300-
bcdata;
301-
ax = ax,
302-
ticks = collect(1:length(bcmap)),
303-
orientation = "vertical",
304-
label = "boundary regions"
305-
)
306-
307285
fig.colorbar(
308286
cdata;
309287
ax = ax,
310-
ticks = collect(1:length(cmap)),
311-
orientation = "vertical",
288+
ticks = 1:length(cmap),
289+
orientation = "$(ctx[:colorbar])",
312290
label = "cell regions"
313291
)
314292
end

0 commit comments

Comments
 (0)