diff --git a/csep/utils/plots.py b/csep/utils/plots.py index e88cc1a7..08ef03ee 100644 --- a/csep/utils/plots.py +++ b/csep/utils/plots.py @@ -1758,9 +1758,9 @@ def plot_comparison_test(results_t, results_w=None, axes=None, plot_args=None): markerfacecolor=facecolor, markeredgecolor=color, markersize=markersize) + ax.set_xticks(numpy.arange(len(results_t))) ax.set_xticklabels([res.sim_name[0] for res in results_t], rotation=xticklabels_rotation, fontsize=xlabel_fontsize) - ax.set_xticks(numpy.arange(len(results_t))) ax.set_xlabel(xlabel) ax.set_ylabel(ylabel, fontsize=ylabel_fontsize) ax.set_title(title) @@ -1769,8 +1769,9 @@ def plot_comparison_test(results_t, results_w=None, axes=None, plot_args=None): ax.yaxis.set_major_locator(matplotlib.ticker.MaxNLocator(integer=True)) ax.set_ylim([ylim[0], ylim[1]]) ax.set_xlim([-0.5, len(results_t) - 0.5]) - ax.bar(xTickPos, numpy.array([9999] * len(xTickPos)), bottom=-2000, - width=(xTickPos[1] - xTickPos[0]), color=['gray', 'w'], alpha=0.2) + if len(results_t) > 2: + ax.bar(xTickPos, numpy.array([9999] * len(xTickPos)), bottom=-2000, + width=(xTickPos[1] - xTickPos[0]), color=['gray', 'w'], alpha=0.2) fig.tight_layout() return ax