Skip to content

Commit

Permalink
include cax for colorbar and adjust extent for cells vs coors plot
Browse files Browse the repository at this point in the history
  • Loading branch information
awirb committed Aug 15, 2023
1 parent c6f72b2 commit e3f2243
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 7 additions & 5 deletions avaframe/out3Plot/outCom1DFA.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,16 +444,18 @@ def plotReleaseScenarioView(avaDir, releaseLine, dem, titleFig, cuSimName):
pU.colorMaps['pft'], np.amin(releaseLine['rasterData']), np.amax(releaseLine['rasterData']),
continuous=pU.contCmap)
cmap1.set_bad(alpha=0.)
extent = [xL - originCells, xL + Lx - originCells, yL + Ly - originCells, yL - originCells]
extentCells = [xL - originCells, xL + Lx - originCells, yL + Ly - originCells, yL - originCells]
extentDem = [xL, xL + Lx, yL + Ly, yL]

# create figure
fig, ax = plt.subplots()
addDem2Plot(ax, dem, what='hillshade', extent='', origHeader=True)
im1 = ax.imshow(rField, extent=extent, cmap=cmap1)
addDem2Plot(ax, dem, what='hillshade', extent=extentDem, origHeader=True)
im1 = ax.imshow(rField, extent=extentCells, cmap=cmap1)
ax.plot(releaseLine['x'], releaseLine['y'], 'b-', label='release polygon')
ax.set_aspect('equal')
pU.addColorBar(im1, ax, ticks, 'm')
plt.legend()
cax = ax.inset_axes([1.04, 0.0, 0.05, 1.])
pU.addColorBar(im1, ax, ticks, 'm', cax=cax)
plt.legend(fontsize=8)
plt.title(titleFig)
pU.putAvaNameOnPlot(ax, avaDir)

Expand Down
2 changes: 2 additions & 0 deletions avaframe/out3Plot/plotUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@ def addColorBar(
extend="neither",
pad=0.05,
tickLabelsList="",
cax=None,
):
"""
Adds, styles and labels a colorbar to the given image and axes
Expand All @@ -529,6 +530,7 @@ def addColorBar(
extend=extend,
pad=pad,
shrink=0.9,
cax=cax,
)
cbar.outline.set_visible(False)
# make sure the cbar title does not overlap with the cbar itself
Expand Down

0 comments on commit e3f2243

Please sign in to comment.