Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

utils.plot: fix _tkinter.TclError via plt.switch_backend('Agg') #947

Merged
merged 2 commits into from
Jan 20, 2023
Merged
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
12 changes: 10 additions & 2 deletions src/mintpy/utils/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -931,14 +931,18 @@ def plot_coherence_matrix(ax, date12List, cohList, date12List_drop=[], p_dict={}
return ax, coh_mat, im


def plot_num_triplet_with_nonzero_integer_ambiguity(fname, display=False, font_size=12, fig_size=[9,3]):
def plot_num_triplet_with_nonzero_integer_ambiguity(fname, disp_fig=False, font_size=12, fig_size=[9,3]):
"""Plot the histogram for the number of triplets with non-zero integer ambiguity.

Fig. 3d-e in Yunjun et al. (2019, CAGEO).

Parameters: fname - str, path to the numTriNonzeroIntAmbiguity.h5 file.
"""

# matplotlib backend setting
if not disp_fig:
plt.switch_backend('Agg')

# read data
data, atr = readfile.read(fname)
vmax = int(np.nanmax(data))
Expand Down Expand Up @@ -983,7 +987,7 @@ def plot_num_triplet_with_nonzero_integer_ambiguity(fname, display=False, font_s
print('plot and save figure to file', out_fig)
fig.savefig(out_fig, bbox_inches='tight', transparent=True, dpi=300)

if display:
if disp_fig:
plt.show()
else:
plt.close(fig)
Expand All @@ -1003,6 +1007,10 @@ def plot_timeseries_rms(rms_file, cutoff=3, out_fig=None, disp_fig=True,
fig_size - list of 2 float, figure size in inch
"""

# matplotlib backend setting
if not disp_fig:
plt.switch_backend('Agg')

# read date / RMS info from text file
fc = np.loadtxt(rms_file, dtype=bytes).astype(str)
rms_list = fc[:, 1].astype(np.float32) * 1000.
Expand Down