Skip to content

Commit

Permalink
PyPlot: fix label position and annotate color bar
Browse files Browse the repository at this point in the history
  • Loading branch information
pjaap committed Nov 18, 2024
1 parent efc3535 commit f697111
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/pyplot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -225,24 +225,34 @@ function gridplot!(ctx, TP::Type{PyPlotType}, ::Type{Val{2}}, grid)
brflag = ones(Bool, nbfaceregions)
ax.set_aspect(ctx[:aspect])
tridat = tridata(grid, ctx[:gridscale])
cmap = region_cmap(ncellregions)
if nbfaceregions 1
# PyPlot.ColorMap cannot handle n ≤ 1, TODO: use other color mapping!
cmap = region_cmap( 2 )
else
cmap = region_cmap(nbfaceregions)
end

cdata = ax.tripcolor(tridat...;
facecolors = cellcolors(grid, ctx[:cellcoloring]),
cmap = PyPlot.ColorMap(cmap, length(cmap)),
vmin = 1.0,
vmax = length(cmap),)
vmin = 0.5,
vmax = length(cmap)+0.5,)
if ctx[:colorbar] == :horizontal
cbar = fig.colorbar(cdata;
ax = ax,
ticks = collect(1:length(cmap)),
orientation = "horizontal",)
orientation = "horizontal",
label = "boundary regions",
)
end

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

ax.triplot(tridat...; color = "k", linewidth = ctx[:linewidth])
Expand Down

0 comments on commit f697111

Please sign in to comment.