From 7bc95db312a51bf06701731a5eb7f62579740627 Mon Sep 17 00:00:00 2001 From: "martin.holmer@gmail.com" Date: Thu, 9 May 2024 15:39:29 -0400 Subject: [PATCH] Revise handling of CLI pch graph --- taxcalc/utils.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/taxcalc/utils.py b/taxcalc/utils.py index 535a83277..3a2e09c8f 100644 --- a/taxcalc/utils.py +++ b/taxcalc/utils.py @@ -1291,8 +1291,8 @@ def pch_graph_plot(data, title = data['title'] fig = bp.figure(width=width, height=height, title=title) fig.title.text_font_size = '12pt' - fig.line(data['line'].index, data['line'].pch, - line_color='blue', line_width=3) + line = data['line'] + fig.line(line.index, line.pch, line_color='blue', line_width=3) fig.circle(0, 0, visible=False) # force zero to be included on y axis zero_grid_line_range = range(0, 101) zero_grid_line_height = [0] * len(zero_grid_line_range) @@ -1308,8 +1308,9 @@ def pch_graph_plot(data, fig.yaxis.axis_label = ylabel fig.yaxis.axis_label_text_font_size = '12pt' fig.yaxis.axis_label_text_font_style = 'normal' - fig.yaxis[0].formatter = PrintfTickFormatter(format='%+.1f%') - return fig + fig.yaxis[0].formatter = PrintfTickFormatter(format='%.1f') + # return fig # bokeh 3.4.1 cannot save this figure for some unknown reason + return None def write_graph_file(figure, filename, title): @@ -1331,9 +1332,10 @@ def write_graph_file(figure, filename, title): ------- Nothing """ - delete_file(filename) # work around annoying 'already exists' bokeh msg - bp.output_file(filename=filename, title=title) - bp.save(figure) + delete_file(filename) + if figure: + bp.output_file(filename=filename, title=title) + bp.save(figure) def isoelastic_utility_function(consumption, crra, cmin):