kylebarron / stata_kernel

A Jupyter kernel for Stata. Works with Windows, macOS, and Linux.
https://kylebarron.dev/stata_kernel/
GNU General Public License v3.0
264 stars 57 forks source link

strange text output in notebook when generating graphs #360

Open charlieeatonphd opened 4 years ago

charlieeatonphd commented 4 years ago

Problem description: I get this:

"cap noi graph hbar Debt_ratio, over(AGI, gap(30)) ytitle("% debt still owed")

asyvars showyvars ylabel(0(25)100, labsize(small)) xsize(4) ysize(6) by(Rac e_Ethnicity, legend(off) title("B: by income") imargin(zero) note("")) name(A GI, replace)

. if _rc == 0 { . noi gr export /Users/Charlie/.stata_kernel_cache/graph$stata_kernel_graph

_counter.svg, width(600) replace"

output in some of my notebooks when running graphs, but not all Notebooks. I haven't been able to figure out what triggers this or how to undo it. I have updated my kernel.

Screen Shot 2020-09-25 at 4 23 57 PM

Debugging log

console_debug.log

Other information

If you didn't attach the debugging log, please provide:

mcaceresb commented 4 years ago

Try set linesize 255? Does the issue persist?

Another thing to try is to split the statement: Something like

local opts asyvars showyvars xsize(4) ysize(6) name(AGI, replace) over(AGI, gap(30))
local opts `opts' ylabel(0(25)100, labsize(small)) ytitle("% debt still owed")
local by   by(Race_Ethnicity, legend(off) title("B: by income") imargin(zero) note(""))
graph hbar Debt_ratio, `opts' `by'

The internal code that makes it so the graphs appear interactively is showing up for some reason. It's probably a parsing issue somewhere, but it's generally difficult to figure out where (the parsing is slightly sensitive because of the way Stata treats line breaks).

charlieeatonphd commented 4 years ago

The set line size did not work.

Using the locals worked great. Cool trick. Thanks!