Skip to content

Commit e216d81

Browse files
committed
FIxed #58. Possible fix of #56
1 parent f00ed92 commit e216d81

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

structure_threader/plotter/structplot.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
# You should have received a copy of the GNU General Public License
1717
# along with structure_threader. If not, see <http://www.gnu.org/licenses/>.
1818

19-
import plotly.plotly as py
2019
from plotly.offline import plot
2120
import plotly.graph_objs as go
2221
from plotly import tools
@@ -643,7 +642,16 @@ def plotk(self, kvals, output_dir):
643642
"""
644643

645644
# Get number of plots (confirm the kvals are valid before)
646-
nplots = len([x for x in kvals if int(x) in self.kvals])
645+
nplots = len([x for x in kvals if int(x) in self.kvals if x >= 1])
646+
647+
# If no valid plots, issue an error
648+
if not nplots:
649+
logging.error("There are no valid K values to plot. \n\n"
650+
"Valid kvals: {}\n"
651+
"Provided kvals: {}\n"
652+
"Exiting.".format(self.kvals.keys(),
653+
kvals))
654+
raise SystemExit(1)
647655

648656
# Set the figure object with the subplots and their titles already
649657
# specified
@@ -859,7 +867,7 @@ def plotk_static(self, kval, output_dir, bw=False, use_ind=False):
859867
former_q = former_q + qvalues[:, i]
860868

861869
# Annotate population info
862-
if self.pops and not use_ind:
870+
if self.pops:
863871
pop_lines = list(OrderedDict.fromkeys(
864872
[x for y in self.pops_xrange for x in y]))[1:-1]
865873

@@ -868,12 +876,13 @@ def plotk_static(self, kval, output_dir, bw=False, use_ind=False):
868876
# Add population delimiting lines
869877
plt.axvline(x=pl - 0.5, linewidth=1.5, color="black")
870878

871-
for p, pos in enumerate(self.pops_xpos):
872-
axe.text(pos, -0.05, self.pops[p],
873-
rotation=45, va="top", ha="right", fontsize=16,
874-
weight="bold")
875-
else:
879+
if not use_ind:
880+
for p, pos in enumerate(self.pops_xpos):
881+
axe.text(pos, -0.05, self.pops[p],
882+
rotation=45, va="top", ha="right", fontsize=16,
883+
weight="bold")
876884

885+
if use_ind or not self.pops:
877886
for pos in range(self.number_indv):
878887
axe.text(pos, -0.05, self.indv[pos],
879888
rotation=45, va="top", ha="right", fontsize=8)

0 commit comments

Comments
 (0)