Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

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

## [1.18.0] - 2026-04-15
- new UnicodePlots.jl extension that at the moment supports gridplot and scalarplot in 1D and 2D

Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "GridVisualize"
uuid = "5eed8a63-0fb0-45eb-886d-8d5a387d12b8"
authors = ["Juergen Fuhrmann <juergen.fuhrmann@wias-berlin.de>", "Patrick Jaap <patrick.jaap@wias-berlin.de>"]
version = "1.18.1"
version = "1.18.2"

[deps]
ColorSchemes = "35d6a980-a343-548e-a6ea-1d62b119f2f4"
Expand Down
32 changes: 19 additions & 13 deletions src/pycommon.jl
Original file line number Diff line number Diff line change
Expand Up @@ -258,30 +258,36 @@ function gridplot!(ctx, TP::Type{T}, ::Type{Val{2}}, grid) where {T <: AbstractP
vmax = length(bcmap) + 0.5,
)

# dummy plot to get a correct color bar for the cell data
cdata = ax.tripcolor(
dummy_coords_x, dummy_coords_y, dummy_triangle; # use the dummy triangle
facecolors = cell_colors[1:1], # only one triangle!
cmap = PyPlotter.ColorMap(cmap, length(cmap)),
vmin = 0.5,
vmax = length(cmap) + 0.5,
)

ax.tripcolor(
tridat...;
facecolors = cell_colors,
cmap = PyPlotter.ColorMap(cmap, length(cmap)),
)

if ctx[:show_colorbar]
if ctx[:colorbar] == :horizontal
cbar = fig.colorbar(
if ctx[:colorbar] in (:horizontal, :vertical)
fig.colorbar(
bcdata;
ax = ax,
ticks = collect(1:length(bcmap)),
orientation = "horizontal",
label = "boundary regions",
ticks = 1:length(bcmap),
orientation = "$(ctx[:colorbar])",
label = "boundary regions"
)
end

if ctx[:colorbar] == :vertical
cbar = fig.colorbar(
bcdata;
fig.colorbar(
cdata;
ax = ax,
ticks = collect(1:length(bcmap)),
orientation = "vertical",
label = "boundary regions",
ticks = 1:length(cmap),
orientation = "$(ctx[:colorbar])",
label = "cell regions"
)
end
end
Expand Down
Loading