diff --git a/taxcalc/taxcalcio.py b/taxcalc/taxcalcio.py index ceb4c3e23..e72d46b66 100644 --- a/taxcalc/taxcalcio.py +++ b/taxcalc/taxcalcio.py @@ -672,6 +672,15 @@ def write_graph_files(self): """ pos_wght_sum = self.calc.total_weight() > 0.0 fig = None + # percentage-aftertax-income-change graph + pch_fname = self._output_filename.replace('.csv', '-pch.html') + pch_title = 'PCH by Income Percentile' + if pos_wght_sum: + fig = self.calc_base.pch_graph(self.calc, pop_quantiles=False) + write_graph_file(fig, pch_fname, pch_title) + else: + reason = 'No graph because sum of weights is not positive' + TaxCalcIO.write_empty_graph_file(pch_fname, pch_title, reason) # average-tax-rate graph atr_fname = self._output_filename.replace('.csv', '-atr.html') atr_title = 'ATR by Income Percentile' @@ -694,15 +703,6 @@ def write_graph_files(self): else: reason = 'No graph because sum of weights is not positive' TaxCalcIO.write_empty_graph_file(mtr_fname, mtr_title, reason) - # percentage-aftertax-income-change graph - pch_fname = self._output_filename.replace('.csv', '-pch.html') - pch_title = 'PCH by Income Percentile' - if pos_wght_sum: - fig = self.calc_base.pch_graph(self.calc, pop_quantiles=False) - write_graph_file(fig, pch_fname, pch_title) - else: - reason = 'No graph because sum of weights is not positive' - TaxCalcIO.write_empty_graph_file(pch_fname, pch_title, reason) if fig: del fig gc.collect()