Skip to content

Commit

Permalink
add plabel, vlabel arguments to export.triplot
Browse files Browse the repository at this point in the history
This patch adds the plabel and vlabel arguments to export.triplot for
the coordinates and values, respectively. For 1D plots the labels are
used for the x and y axes; for 2D plots the plabel is used for both x
and y and the vlabel is used for the colorbar.
  • Loading branch information
gertjanvanzwieten committed Dec 30, 2021
1 parent 8b2ad09 commit 63f5613
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions nutils/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ def plotlines_(ax, xy, lines, **kwargs):
ax.add_collection(lc)
return lc

def triplot(name, points, values=None, *, tri=None, hull=None, cmap=None, clim=None, linewidth=.1, linecolor='k'):
def triplot(name, points, values=None, *, tri=None, hull=None, cmap=None, clim=None, linewidth=.1, linecolor='k', plabel=None, vlabel=None):
if (tri is None) != (values is None):
raise Exception('tri and values can only be specified jointly')
with mplfigure(name) as fig:
if points.shape[1] == 1:
ax = fig.add_subplot(111)
ax = fig.add_subplot(111, xlabel=plabel, ylabel=vlabel)
if tri is not None:
plotlines_(ax, [points[:,0], values], tri)
if hull is not None:
Expand All @@ -77,12 +77,12 @@ def triplot(name, points, values=None, *, tri=None, hull=None, cmap=None, clim=N
else:
ax.set_ylim(clim)
elif points.shape[1] == 2:
ax = fig.add_subplot(111, aspect='equal')
ax = fig.add_subplot(111, xlabel=plabel, ylabel=plabel, aspect='equal')
if tri is not None:
im = ax.tripcolor(*points.T, tri, values, shading='gouraud', cmap=cmap, rasterized=True)
if clim is not None:
im.set_clim(clim)
fig.colorbar(im)
fig.colorbar(im, label=vlabel)
if hull is not None:
plotlines_(ax, points.T, hull, colors=linecolor, linewidths=linewidth, alpha=1 if tri is None else .5)
ax.autoscale(enable=True, axis='both', tight=True)
Expand Down

0 comments on commit 63f5613

Please sign in to comment.