Probability Outcomes Plot with JULIA for Fair Coin Tossing

That’s weird, it works for me with Julia 1.7.3 and the same version of TikzPictures. Can you get any of the TikzPictures.jl examples to work? Maybe this has something to do with the TeX engine.

It’s a bit hard to debug like this, but if you execute tikzDeleteIntermediate(false) before saving the file, you should get a temporary directory (named jl_XXX) in your project’s directory. Inside you should find a .log file and a .tex file. If you upload these two files here (drag and drop to the reply text editor), and also the notebook file, I could have a look.

I can’t upload .tex and .log files

here I attach the screenshot.

It can’t even be run on TeXStudio to produce the pdf.

Capture d’écran_2023-02-16_19-56-59

I copy paste the loge here:

This is pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017/Debian) (preloaded format=pdflatex 2021.10.6)  16 FEB 2023 19:26
entering extended mode
 restricted \write18 enabled.
 %&-line parsing enabled.
**tikzpicture.tex
(./tikzpicture.tex
LaTeX2e <2017-04-15>
Babel <3.18> and hyphenation patterns for 84 language(s) loaded.
(/usr/share/texlive/texmf-dist/tex/latex/standalone/standalone.cls
Document Class: standalone 2015/07/15 v1.2 Class to compile TeX sub-files stand
alone
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifluatex.sty
Package: ifluatex 2016/05/16 v1.4 Provides the ifluatex switch (HO)
Package ifluatex Info: LuaTeX not detected.
)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifpdf.sty
Package: ifpdf 2017/03/15 v3.2 Provides the ifpdf switch
)
(/usr/share/texlive/texmf-dist/tex/generic/ifxetex/ifxetex.sty
Package: ifxetex 2010/09/12 v0.6 Provides ifxetex conditional
)
(/usr/share/texlive/texmf-dist/tex/latex/xkeyval/xkeyval.sty
Package: xkeyval 2014/12/03 v2.7a package option processing (HA)

(/usr/share/texlive/texmf-dist/tex/generic/xkeyval/xkeyval.tex
(/usr/share/texlive/texmf-dist/tex/generic/xkeyval/xkvutils.tex
\XKV@toks=\toks14
\XKV@tempa@toks=\toks15

(/usr/share/texlive/texmf-dist/tex/generic/xkeyval/keyval.tex))
\XKV@depth=\count79
File: xkeyval.tex 2014/12/03 v2.7a key=value parser (HA)
))
\sa@internal=\count80
\c@sapage=\count81

(/usr/share/texlive/texmf-dist/tex/latex/standalone/standalone.cfg
File: standalone.cfg 2015/07/15 v1.2 Default configuration file for 'standalone
' class
)
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo
File: size10.clo 2014/09/29 v1.4h Standard LaTeX file (size option)
)
\c@part=\count82
\c@section=\count83
\c@subsection=\count84
\c@subsubsection=\count85
\c@paragraph=\count86
\c@subparagraph=\count87
\c@figure=\count88
\c@table=\count89
\abovecaptionskip=\skip41
\belowcaptionskip=\skip42
\bibindent=\dimen102
)
(/usr/share/texlive/texmf-dist/tex/latex/pgf/frontendlayer/tikz.sty
(/usr/share/texlive/texmf-dist/tex/latex/pgf/basiclayer/pgf.sty
(/usr/share/texlive/texmf-dist/tex/latex/pgf/utilities/pgfrcs.sty
(/usr/share/texlive/texmf-dist/tex/generic/pgf/utilities/pgfutil-common.tex
\pgfutil@everybye=\toks16
\pgfutil@tempdima=\dimen103
\pgfutil@tempdimb=\dimen104

(/usr/share/texlive/texmf-dist/tex/generic/pgf/utilities/pgfutil-common-lists.t
ex)) (/usr/share/texlive/texmf-dist/tex/generic/pgf/utilities/pgfutil-latex.def
\pgfutil@abb=\box26
(/usr/share/texlive/texmf-dist/tex/latex/ms/everyshi.sty
Package: everyshi 2001/05/15 v3.00 EveryShipout Package (MS)
))
(/usr/share/texlive/texmf-dist/tex/generic/pgf/utilities/pgfrcs.code.tex
Package: pgfrcs 2015/08/07 v3.0.1a (rcs-revision 1.31)
))
Package: pgf 2015/08/07 v3.0.1a (rcs-revision 1.15)

(/usr/share/texlive/texmf-dist/tex/latex/pgf/basiclayer/pgfcore.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics/graphicx.sty
Package: graphicx 2017/06/01 v1.1a Enhanced LaTeX Graphics (DPC,SPQR)

(/usr/share/texlive/texmf-dist/tex/latex/graphics/graphics.sty
Package: graphics 2017/06/25 v1.2c Standard LaTeX Graphics (DPC,SPQR)

(/usr/share/texlive/texmf-dist/tex/latex/graphics/trig.sty
Package: trig 2016/01/03 v1.10 sin cos tan (DPC)
)
(/usr/share/texlive/texmf-dist/tex/latex/graphics-cfg/graphics.cfg
File: graphics.cfg 2016/06/04 v1.11 sample graphics configuration
)
Package graphics Info: Driver file: pdftex.def on input line 99.

(/usr/share/texlive/texmf-dist/tex/latex/graphics-def/pdftex.def
File: pdftex.def 2018/01/08 v1.0l Graphics/color driver for pdftex
))
\Gin@req@height=\dimen105
\Gin@req@width=\dimen106
)
(/usr/share/texlive/texmf-dist/tex/latex/pgf/systemlayer/pgfsys.sty
(/usr/share/texlive/texmf-dist/tex/generic/pgf/systemlayer/pgfsys.code.tex
Package: pgfsys 2014/07/09 v3.0.1a (rcs-revision 1.48)

(/usr/share/texlive/texmf-dist/tex/generic/pgf/utilities/pgfkeys.code.tex
\pgfkeys@pathtoks=\toks17
\pgfkeys@temptoks=\toks18

(/usr/share/texlive/texmf-dist/tex/generic/pgf/utilities/pgfkeysfiltered.code.t
ex
\pgfkeys@tmptoks=\toks19
))
\pgf@x=\dimen107
\pgf@y=\dimen108
\pgf@xa=\dimen109
\pgf@ya=\dimen110
\pgf@xb=\dimen111
\pgf@yb=\dimen112
\pgf@xc=\dimen113
\pgf@yc=\dimen114
\w@pgf@writea=\write3
\r@pgf@reada=\read1
\c@pgf@counta=\count90
\c@pgf@countb=\count91
\c@pgf@countc=\count92
\c@pgf@countd=\count93
\t@pgf@toka=\toks20
\t@pgf@tokb=\toks21
\t@pgf@tokc=\toks22
 (/usr/share/texlive/texmf-dist/tex/generic/pgf/systemlayer/pgf.cfg
File: pgf.cfg 2008/05/14  (rcs-revision 1.7)
)
Driver file for pgf: pgfsys-pdftex.def

(/usr/share/texlive/texmf-dist/tex/generic/pgf/systemlayer/pgfsys-pdftex.def
File: pgfsys-pdftex.def 2014/10/11  (rcs-revision 1.35)

(/usr/share/texlive/texmf-dist/tex/generic/pgf/systemlayer/pgfsys-common-pdf.de
f
File: pgfsys-common-pdf.def 2013/10/10  (rcs-revision 1.13)
)))
(/usr/share/texlive/texmf-dist/tex/generic/pgf/systemlayer/pgfsyssoftpath.code.
tex
File: pgfsyssoftpath.code.tex 2013/09/09  (rcs-revision 1.9)
\pgfsyssoftpath@smallbuffer@items=\count94
\pgfsyssoftpath@bigbuffer@items=\count95
)
(/usr/share/texlive/texmf-dist/tex/generic/pgf/systemlayer/pgfsysprotocol.code.
tex
File: pgfsysprotocol.code.tex 2006/10/16  (rcs-revision 1.4)
)) (/usr/share/texlive/texmf-dist/tex/latex/xcolor/xcolor.sty
Package: xcolor 2016/05/11 v2.12 LaTeX color extensions (UK)

(/usr/share/texlive/texmf-dist/tex/latex/graphics-cfg/color.cfg
File: color.cfg 2016/01/02 v1.6 sample color configuration
)
Package xcolor Info: Driver file: pdftex.def on input line 225.
Package xcolor Info: Model `cmy' substituted by `cmy0' on input line 1348.
Package xcolor Info: Model `hsb' substituted by `rgb' on input line 1352.
Package xcolor Info: Model `RGB' extended on input line 1364.
Package xcolor Info: Model `HTML' substituted by `rgb' on input line 1366.
Package xcolor Info: Model `Hsb' substituted by `hsb' on input line 1367.
Package xcolor Info: Model `tHsb' substituted by `hsb' on input line 1368.
Package xcolor Info: Model `HSB' substituted by `hsb' on input line 1369.
Package xcolor Info: Model `Gray' substituted by `gray' on input line 1370.
Package xcolor Info: Model `wave' substituted by `hsb' on input line 1371.
)
(/usr/share/texlive/texmf-dist/tex/generic/pgf/basiclayer/pgfcore.code.tex
Package: pgfcore 2010/04/11 v3.0.1a (rcs-revision 1.7)

(/usr/share/texlive/texmf-dist/tex/generic/pgf/math/pgfmath.code.tex
(/usr/share/texlive/texmf-dist/tex/generic/pgf/math/pgfmathcalc.code.tex
(/usr/share/texlive/texmf-dist/tex/generic/pgf/math/pgfmathutil.code.tex)
(/usr/share/texlive/texmf-dist/tex/generic/pgf/math/pgfmathparser.code.tex
\pgfmath@dimen=\dimen115
\pgfmath@count=\count96
\pgfmath@box=\box27
\pgfmath@toks=\toks23
\pgfmath@stack@operand=\toks24
\pgfmath@stack@operation=\toks25
)
(/usr/share/texlive/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.code.tex
(/usr/share/texlive/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.basic.code
.tex)
(/usr/share/texlive/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.trigonomet
ric.code.tex)
(/usr/share/texlive/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.random.cod
e.tex)
(/usr/share/texlive/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.comparison
.code.tex)
(/usr/share/texlive/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.base.code.
tex)
(/usr/share/texlive/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.round.code
.tex)
(/usr/share/texlive/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.misc.code.
tex)
(/usr/share/texlive/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.integerari
thmetics.code.tex)))
(/usr/share/texlive/texmf-dist/tex/generic/pgf/math/pgfmathfloat.code.tex
\c@pgfmathroundto@lastzeros=\count97
))
(/usr/share/texlive/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepoints.code.te
x
File: pgfcorepoints.code.tex 2013/10/07  (rcs-revision 1.27)
\pgf@picminx=\dimen116
\pgf@picmaxx=\dimen117
\pgf@picminy=\dimen118
\pgf@picmaxy=\dimen119
\pgf@pathminx=\dimen120
\pgf@pathmaxx=\dimen121
\pgf@pathminy=\dimen122
\pgf@pathmaxy=\dimen123
\pgf@xx=\dimen124
\pgf@xy=\dimen125
\pgf@yx=\dimen126
\pgf@yy=\dimen127
\pgf@zx=\dimen128
\pgf@zy=\dimen129
)
(/usr/share/texlive/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepathconstruct.
code.tex
File: pgfcorepathconstruct.code.tex 2013/10/07  (rcs-revision 1.29)
\pgf@path@lastx=\dimen130
\pgf@path@lasty=\dimen131
)
(/usr/share/texlive/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepathusage.code
.tex
File: pgfcorepathusage.code.tex 2014/11/02  (rcs-revision 1.24)
\pgf@shorten@end@additional=\dimen132
\pgf@shorten@start@additional=\dimen133
)
(/usr/share/texlive/texmf-dist/tex/generic/pgf/basiclayer/pgfcorescopes.code.te
x
File: pgfcorescopes.code.tex 2015/05/08  (rcs-revision 1.46)
\pgfpic=\box28
\pgf@hbox=\box29
\pgf@layerbox@main=\box30
\pgf@picture@serial@count=\count98
)
(/usr/share/texlive/texmf-dist/tex/generic/pgf/basiclayer/pgfcoregraphicstate.c
ode.tex
File: pgfcoregraphicstate.code.tex 2014/11/02  (rcs-revision 1.12)
\pgflinewidth=\dimen134
)
(/usr/share/texlive/texmf-dist/tex/generic/pgf/basiclayer/pgfcoretransformation
s.code.tex
File: pgfcoretransformations.code.tex 2015/08/07  (rcs-revision 1.20)
\pgf@pt@x=\dimen135
\pgf@pt@y=\dimen136
\pgf@pt@temp=\dimen137
)
(/usr/share/texlive/texmf-dist/tex/generic/pgf/basiclayer/pgfcorequick.code.tex
File: pgfcorequick.code.tex 2008/10/09  (rcs-revision 1.3)
)
(/usr/share/texlive/texmf-dist/tex/generic/pgf/basiclayer/pgfcoreobjects.code.t
ex
File: pgfcoreobjects.code.tex 2006/10/11  (rcs-revision 1.2)
)
(/usr/share/texlive/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepathprocessing
.code.tex
File: pgfcorepathprocessing.code.tex 2013/09/09  (rcs-revision 1.9)
)
(/usr/share/texlive/texmf-dist/tex/generic/pgf/basiclayer/pgfcorearrows.code.te
x
File: pgfcorearrows.code.tex 2015/05/14  (rcs-revision 1.43)
\pgfarrowsep=\dimen138
)
(/usr/share/texlive/texmf-dist/tex/generic/pgf/basiclayer/pgfcoreshade.code.tex
File: pgfcoreshade.code.tex 2013/07/15  (rcs-revision 1.15)
\pgf@max=\dimen139
\pgf@sys@shading@range@num=\count99
)
(/usr/share/texlive/texmf-dist/tex/generic/pgf/basiclayer/pgfcoreimage.code.tex
File: pgfcoreimage.code.tex 2013/07/15  (rcs-revision 1.18)

(/usr/share/texlive/texmf-dist/tex/generic/pgf/basiclayer/pgfcoreexternal.code.
tex
File: pgfcoreexternal.code.tex 2014/07/09  (rcs-revision 1.21)
\pgfexternal@startupbox=\box31
))
(/usr/share/texlive/texmf-dist/tex/generic/pgf/basiclayer/pgfcorelayers.code.te
x
File: pgfcorelayers.code.tex 2013/07/18  (rcs-revision 1.7)
)
(/usr/share/texlive/texmf-dist/tex/generic/pgf/basiclayer/pgfcoretransparency.c
ode.tex
File: pgfcoretransparency.code.tex 2013/09/30  (rcs-revision 1.5)
)
(/usr/share/texlive/texmf-dist/tex/generic/pgf/basiclayer/pgfcorepatterns.code.
tex
File: pgfcorepatterns.code.tex 2013/11/07  (rcs-revision 1.5)
)))

I try example on github and it is working on REPL to produce the pdf…

is it the " problems?

Could you also paste the content of the .tex file?

Here you go :slight_smile:

\documentclass[tikz]{standalone}

\begin{document}
\begin{tikzpicture}[grow=right]
\node {}
  child [sibling distance=20ex] { node {T}
    child [sibling distance=10ex] { node {T}
      child [sibling distance=5ex]
        { node [anchor=west] { T $\cdots$ (T,T,T)\; $p = \frac{1}{8}$ } }
      child [sibling distance=5ex]
        { node [anchor=west] { H $\cdots$ (T,T,H)\; $p = \frac{1}{8}$ } }
    }
    child [sibling distance=10ex] { node {H}
      child [sibling distance=5ex]
        { node [anchor=west] { T $\cdots$ (T,H,T)\; $p = \frac{1}{8}$ } }
      child [sibling distance=5ex]
        { node [anchor=west] { H $\cdots$ (T,H,H)\; $p = \frac{1}{8}$ } }
    }
  }
  child [sibling distance=20ex] { node {H}
    child [sibling distance=10ex] { node {T}
      child [sibling distance=5ex]
        { node [anchor=west] { T $\cdots$ (H,T,T)\; $p = \frac{1}{8}$ } }
      child [sibling distance=5ex]
        { node [anchor=west] { H $\cdots$ (H,T,H)\; $p = \frac{1}{8}$ } }
    }
    child [sibling distance=10ex] { node {H}
      child [sibling distance=5ex]
        { node [anchor=west] { T $\cdots$ (H,H,T)\; $p = \frac{1}{8}$ } }
      child [sibling distance=5ex]
        { node [anchor=west] { H $\cdots$ (H,H,H)\; $p = \frac{1}{8}$ } }
    }
  };
\end{tikzpicture}

\end{document}

It’s probably best to try and solve this in a chat.

Yes!

Could you share the whole code to both generate the bit strings and the graph?

using Graphs, NetworkLayout
using PlotlyJS

function adjacency_btree(h::Int)
    nn = 2^(h+1)-1 #number of nodes
    A = zeros(Int, nn, nn);
    labels = [""]
    j=2
    for i = 1:2^h-1
        A[i, j] = A[i, j+1] = 1
        append!(labels, ["<b>0</b>", "<b>1</b>"])
        j=j+2
    end 
    return A, labels
end 
function perfect_btree(h::T, A:: Matrix{T}) where T<:Integer
    G = DiGraph(A);
    node_pos = buchheim(G.fadjlist)
    #rotate the node positions with pi/2 about root (by defaul it's the origin) to get an horizontal tree
    mcoords = hcat([-P[2] for P in node_pos], [P[1] for P in node_pos])
    xn, yn = eachcol(mcoords); #new node corrdinates
    E = [(e.src, e.dst) for e in edges(G)]
    xe, ye = get_plotly_data(E, xn , yn);
    xs, ys = eachcol(mcoords[2^h:end, :]) #the coordinates of points near leafs to display bistrings
    return xn, yn, xe, ye,  xs, ys
end 

#T=Int8 is sufficient for tree depth, h=4, 5, 6, 7
bit_strings(h::Int;T=Int8)= String[bitstring(T(i))[sizeof(T)*8-h+1:end]   for i in 0:2^h-1]

function get_plotly_data(E, xcoord, ycoord)
    # E is the vector of tuples representing the graph edges
    # xcoord, ycoords is the vectors of node coordinates

    Xedges = Float64[]
    Yedges = Float64[]
    for e in E
        append!(Xedges, [xcoord[e[1]], xcoord[e[2]], NaN])
        append!(Yedges, [ycoord[e[1]], ycoord[e[2]], NaN])
    end
    return Xedges, Yedges
end

const h=4
A, labels = adjacency_btree(h)
xn, yn, xe, ye,  xs, ys = perfect_btree(h, A)
vbstr= ["<b>$s</b>" for s in bit_strings(h;)]
fig = Plot([scatter(
                x=xe,
                y=ye,
                mode="lines",
                line_color="#d2d2d2",
                line_width=1.5,
                hoverinfo="none"),
           scatter(
                x=xn, 
                y=yn, 
                mode="markers+text",
                name=" ",
                text=labels,
            marker_size=18, marker_color="rgb(255, 200, 0)",
                hoverinfo="text")], 
                Layout(height=600, width=600, xaxis_visible=false, yaxis_visible=false,
                       font_size=16, font_family="Open Sherif", plot_bgcolor="#000000",
                       showlegend=false))
#one more traces to display the corresponding bitsring for each leaf
addtraces!(fig, scatter(x=xs .+0.6, y=ys, mode="text", text =vbstr, textfont_color="#d2d2d2"))
display(fig)    
2 Likes