From bb5e726ba27317bf82829163407a4363211228ab Mon Sep 17 00:00:00 2001 From: joaomcteixeira Date: Thu, 13 Dec 2018 19:34:27 +0100 Subject: [PATCH 1/2] improved x axis ticks in bar plots --- core/fslibs/FarseerSeries.py | 92 +++++++++++++++++++++++++----------- 1 file changed, 64 insertions(+), 28 deletions(-) diff --git a/core/fslibs/FarseerSeries.py b/core/fslibs/FarseerSeries.py index 0a280c8..7a1afe6 100644 --- a/core/fslibs/FarseerSeries.py +++ b/core/fslibs/FarseerSeries.py @@ -1291,17 +1291,25 @@ def plot_bar_horizontal( # ticks positions: # this is used to fit both applyFASTA=True or False # reduces xticks to 100 as maximum to avoid ticklabel overlap - if self.shape[1] > 100: - xtick_spacing = self.shape[1]//100 - else: - xtick_spacing = 1 + + ## quick patch introduced in 1.3.1 to solve x axis issue + ## before release of version 1.4.0 + # Define tick spacing + for j in range(101,10000,100): + if j>len(bars): + mod_ = j//100 + break + self.logger.debug("Tick spacing set to: {}".format(mod_)) + + # set xticks and xticks_labels to be represented + xticks = np.arange(len(bars))[0::mod_] ticklabels = \ - self.loc[experiment,0::xtick_spacing,['ResNo','1-letter']].\ + self.loc[experiment,0::mod_,['ResNo','1-letter']].\ apply(lambda x: ''.join(x), axis=1) # Configure XX ticks and Label - axs[i].set_xticks(self.major_axis) + axs[i].set_xticks(xticks) ## https://github.com/matplotlib/matplotlib/issues/6266 axs[i].set_xticklabels( ticklabels, @@ -1315,7 +1323,7 @@ def plot_bar_horizontal( if x_ticks_color_flag: self._set_item_colors( axs[i].get_xticklabels(), - self.loc[experiment,0::xtick_spacing,'Peak Status'], + self.loc[experiment,0::mod_,'Peak Status'], { 'measured':measured_color, 'missing':missing_color, @@ -1361,7 +1369,7 @@ def plot_bar_horizontal( elif plot_style == 'bar_compacted': bars = axs[i].bar( - self.loc[experiment,:,'ResNo'].astype(float), + self.major_axis, self.loc[experiment,:,calccol].fillna(0), width=bar_width, align='center', @@ -1370,19 +1378,37 @@ def plot_bar_horizontal( zorder=4 ) - initialresidue = int(self.ix[0, 0, 'ResNo']) - finalresidue = int(self.loc[experiment,:,'ResNo'].tail(1)) + ## quick patch introduced in 1.3.1 to solve x axis issue + ## before release of version 1.4.0 + num_of_bars = len(bars) + number_of_ticks = num_of_bars + mod_ = 10 + sanity_counter = 0 - if self.shape[1] > 100: - xtick_spacing = self.shape[1]//100*10 + tmp_xticks = self.loc[experiment,:,'ResNo'].astype(float) - else: - xtick_spacing = 10 + while number_of_ticks > 10 and sanity_counter < 100000: + + mask = np.where(tmp_xticks % mod_ == 0)[0] + + xticks = self.major_axis[mask] #np.arange(num_of_bars)[mask] + xticks_labels = self.loc[experiment,mask,'ResNo'] + number_of_ticks = len(xticks) + + mod_ *= 10 + sanity_counter += 1 - first_tick = ceil(initialresidue/10)*xtick_spacing - xtickarange = np.arange(first_tick, finalresidue+1, xtick_spacing) - axs[i].set_xticks(xtickarange) - # https://github.com/matplotlib/matplotlib/issues/6266 + self.logger.debug("sanity_counter: {}".format(sanity_counter)) + + # set xticks and xticks_labels to be represented + self.logger.debug("xticks represented: {}".format(xticks)) + self.logger.debug("xticks labels represented: {}".format(xticks_labels)) + + # Set X ticks + axs[i].set_xticks(xticks) + xtickarange = xticks_labels + + # # https://github.com/matplotlib/matplotlib/issues/6266 axs[i].set_xticklabels( xtickarange, fontname=x_ticks_fn, @@ -1396,7 +1422,7 @@ def plot_bar_horizontal( self.loc[experiment, :, 'Peak Status'] == 'unassigned' for residue in self.loc[experiment, unassignedmask, 'ResNo']: - residue = int(residue) - 0.5 + residue = int(residue) - 1.5 axs[i].axvspan( residue, residue+1, @@ -1637,16 +1663,26 @@ def plot_bar_vertical( ## Configure XX ticks and Label axs[i].margins(y=0.01) - if self.shape[1] > 100: - xtick_spacing = self.shape[1]//100 - - else: - xtick_spacing = 1 - - axs[i].set_yticks(self.major_axis) + ## quick patch introduced in 1.3.1 to solve x axis issue + ## before release of version 1.4.0 + # Define tick spacing + for j in range(101,10000,100): + if j>len(bars): + mod_ = j//100 + break + self.logger.debug("Tick spacing set to: {}".format(mod_)) + + # set xticks and xticks_labels to be represented + xticks = np.arange(len(bars))[0::mod_] + + ticklabels = \ + self.loc[experiment,0::mod_,['ResNo','1-letter']].\ + apply(lambda x: ''.join(x), axis=1) + # Configure XX ticks and Label + axs[i].set_yticks(xticks) # https://github.com/matplotlib/matplotlib/issues/6266 axs[i].set_yticklabels( - self.loc[experiment,0::xtick_spacing,['ResNo','1-letter']].\ + self.loc[experiment,0::mod_,['ResNo','1-letter']].\ apply(lambda x: ''.join(x), axis=1), fontname=x_ticks_fn, fontsize=x_ticks_fs-2, @@ -1667,7 +1703,7 @@ def plot_bar_vertical( if x_ticks_color_flag: self._set_item_colors( axs[i].get_yticklabels(), - self.loc[experiment,0::xtick_spacing,'Peak Status'], + self.loc[experiment,0::mod_,'Peak Status'], { 'measured':measured_color, 'missing':missing_color, From a0b77544ad6b10d32bce61b9554504d98d4c97bc Mon Sep 17 00:00:00 2001 From: joaomcteixeira Date: Thu, 13 Dec 2018 19:48:59 +0100 Subject: [PATCH 2/2] updated version numbering --- install/messages.py | 67 ++++++++++++++++++++++----------------------- install/system.py | 2 +- 2 files changed, 34 insertions(+), 35 deletions(-) diff --git a/install/messages.py b/install/messages.py index 94030dd..2d163d5 100644 --- a/install/messages.py +++ b/install/messages.py @@ -302,40 +302,39 @@ def _formats_short_title(s): """ # http://patorjk.com/software/taag/#p=display&h=1&f=Doom&t=---------%0AFarSeer-NMR%0Av1.3.0%0A--------- -banner = \ -""" - - - ______ ______ ______ ______ ______ ______ ______ ______ ______ -|______||______||______||______||______||______||______||______||______| - - - - -______ _____ _ _ ___ _________ -| ___| / ___| | \ | || \/ || ___ \ -| |_ __ _ _ __\ `--. ___ ___ _ __ ______ | \| || . . || |_/ / -| _|/ _` || '__|`--. \ / _ \ / _ \| '__||______|| . ` || |\/| || / -| | | (_| || | /\__/ /| __/| __/| | | |\ || | | || |\ \ -\_| \__,_||_| \____/ \___| \___||_| \_| \_/\_| |_/\_| \_| - - - __ _____ _____ - / | |____ | | _ | -__ __`| | / / | |/' | -\ \ / / | | \ \ | /| | - \ V / _| |_ _ .___/ /_\ |_/ / - \_/ \___/(_)\____/(_)\___/ - - - - - ______ ______ ______ ______ ______ ______ ______ ______ ______ -|______||______||______||______||______||______||______||______||______| - - - - +banner = r""" + + + ______ ______ ______ ______ ______ ______ ______ ______ ______ +|______||______||______||______||______||______||______||______||______| + + + + +______ _____ _ _ ___ _________ +| ___| / ___| | \ | || \/ || ___ \ +| |_ __ _ _ __\ `--. ___ ___ _ __ ______ | \| || . . || |_/ / +| _|/ _` || '__|`--. \ / _ \ / _ \| '__||______|| . ` || |\/| || / +| | | (_| || | /\__/ /| __/| __/| | | |\ || | | || |\ \ +\_| \__,_||_| \____/ \___| \___||_| \_| \_/\_| |_/\_| \_| + + + __ _____ __ + / | |____ | / | +__ __`| | / / `| | +\ \ / / | | \ \ | | + \ V / _| |_ _ .___/ /_ _| |_ + \_/ \___/(_)\____/(_)\___/ + + + + + ______ ______ ______ ______ ______ ______ ______ ______ ______ +|______||______||______||______||______||______||______||______||______| + + + + """ if __name__ == "__main__": diff --git a/install/system.py b/install/system.py index 52088ae..767337d 100644 --- a/install/system.py +++ b/install/system.py @@ -39,7 +39,7 @@ import platform as pltfrm import os -farseer_version = (1, 3, 0) # v1.3.0 +farseer_version = (1, 3, 1) # v1.3.0 min_space_allowed = 3 # GB