Commit 85a389f1 authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Bugfix, enhancement

components.plotting:
- subplot_imshow(): changes color map to 'gray' (fixes color inversion)

components.Tie_Point_Grid.Tie_Point_Grid:
- plot_shift_distribution(): revised legend appearance

updated __version__
parent be709baf
......@@ -9,7 +9,7 @@ from .components import utilities
from .components import geometry
__author__ = 'Daniel Scheffler'
__version__= '2017-04-28_02'
__version__= '2017-05-03_01'
__all__=['COREG',
'COREG_LOCAL',
......
......@@ -449,6 +449,7 @@ class Tie_Point_Grid(object):
ax.set_xlim(xlim)
ax.set_ylim(ylim)
# add text box containing RMSE of plotted shifts
xlim, ylim = ax.get_xlim(), ax.get_ylim()
plt.text(xlim[1]-(xlim[1]/20),-ylim[1]+(ylim[1]/20),
'RMSE: %s m / %s px' %(np.round(rmse, 2), np.round(rmse/self.shift.xgsd, 2)),
......@@ -465,16 +466,18 @@ class Tie_Point_Grid(object):
middle_ygl.set_linewidth(2)
middle_ygl.set_linestyle('-')
# set title and adjust tick labels
ax.set_title(title, fontsize=fontsize)
[tick.label.set_fontsize(fontsize) for tick in ax.xaxis.get_major_ticks()]
[tick.label.set_fontsize(fontsize) for tick in ax.yaxis.get_major_ticks()]
plt.xlabel('x-shift [%s]' % 'meters' if unit == 'm' else 'pixels', fontsize=fontsize)
plt.ylabel('y-shift [%s]' % 'meters' if unit == 'm' else 'pixels', fontsize=fontsize)
# add legend with labels in the right order
handles, labels = ax.get_legend_handles_labels()
plt.legend(reversed(handles), reversed(labels), fontsize=fontsize, loc='upper right')
leg = plt.legend(reversed(handles), reversed(labels), fontsize=fontsize, loc='upper right', scatterpoints=3)
leg.get_frame().set_edgecolor('black')
ax.set_title(title, fontsize=fontsize)
plt.xlabel('x-shift [%s]' % 'meters' if unit == 'm' else 'pixels', fontsize=fontsize)
plt.ylabel('y-shift [%s]' % 'meters' if unit == 'm' else 'pixels', fontsize=fontsize)
plt.show()
return fig, ax
......
......@@ -23,13 +23,16 @@ def subplot_2dline(XY_tuples, titles=None, shapetuple=None, grid=False):
def subplot_imshow(ims, titles=None, shapetuple=None, grid=False):
ims = [ims] if not isinstance(ims,list) else ims
assert titles is None or len(titles)==len(ims), 'Error: Got more or less titles than images.'
shapetuple = (1,len(ims)) if shapetuple is None else shapetuple
norm = lambda array, normto: [float(i)*(normto/max(array)) for i in array]
fig,axes = plt.subplots(shapetuple[0],shapetuple[1], figsize=norm(plt.figaspect(shapetuple[0]/shapetuple[1]*1.), 20))
[axes[i].imshow(im,cmap='binary',interpolation='none', vmin=np.percentile(im,2), vmax = np.percentile(im,98)) \
[axes[i].imshow(im,cmap='gray',interpolation='none', vmin=np.percentile(im,2), vmax = np.percentile(im,98)) \
for i,im in enumerate(ims)]
if titles is not None: [axes[i].set_title(titles[i]) for i in range(len(ims))]
if grid: [axes[i].grid(which='major', axis='both', linestyle='-') for i in range(len(ims))]
if titles is not None:
[axes[i].set_title(titles[i]) for i in range(len(ims))]
if grid:
[axes[i].grid(which='major', axis='both', linestyle='-') for i in range(len(ims))]
plt.tight_layout()
plt.show(block=True)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment