Giter Site home page Giter Site logo

dot2tex's Introduction

dot2tex - A Graphviz to LaTeX converter

WARNING: This project is no longer being maintained. I have tried to find a new maintainer for the project with no luck. If you are interested, feel free to reach out. See #58 for details.

License: MIT (See LICENSE for details.)

Version: 2.12.dev

URL: https://github.com/xyz2tex/dot2tex

Documentation: http://dot2tex.readthedocs.org/

Dot2tex is a tool for converting graphs rendered by Graphviz to formats that can be used with LaTeX.

Installation

Before you install dot2tex you have to have a working Python environment installed on your system. Dot2tex works with Python 2.7 and Python 3. In addition you'll need the following modules:

  • pyparsing. A recent version is required. Older version like for instance 1.3.2 does not work with dot2tex.
  • preview A stand-alone part of the preview-latex/AUCTeX bundle. Required for preprocessing graphs with LaTeX.
  • PGF/TikZ 2.0 or later required.

Note. If you have dot2tex version 2.5.0 or older installed, please remove the old version of the dot2tex.py file in your SCRIPTS directory before you install the latest dot2tex version. Otherwise the new dot2tex wrapper script will try to load the dot2tex.py as a module.

Using pip

The easiest way to install dot2tex is to use pip:

$ pip install dot2tex

The command will locate dot2tex and download it automatically along with dependencies. Note that documentation and examples are not installed by default.

Binary packages

Binary packages are available for Debian and OpenSUSE.

From source

Download a zip or a tarball from the download_ page. Unpack the file to a directory and run python on the setup.py file:

$ python setup.py install

This will create a dot2tex module in your Python module directory and a wrapper script in your SCRIPTS directory. Note that a few warnings will be displayed. You can safely ignore them. The warnings are shown because there is some extra information in the setup.py file that distutils does not understand.

Development version

The development version of dot2tex is available on GitHub.

Contribute

dot2tex's People

Contributors

adl avatar alexhagen avatar apn-pucky avatar arbipher avatar atry avatar epicorange avatar fchapoton avatar gabebolton avatar holzhaus avatar jcapucho avatar jimon avatar johnyf avatar kjellmf avatar mrprajesh avatar ncfavier avatar petfold avatar rcurtin avatar ruifengx avatar sashank27 avatar sceptical-coder avatar setser avatar tjni avatar tscrim avatar vftdan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

dot2tex's Issues

subgraph's border line is not drawn

I have some issue with subgraph. I have to use node attribute, like `node [shape=box]', to get the border of subgraph drawn.

The situation is worse with Chinese characters; the attribute does not help any more. But when remove one Chinese character from node name ``三四五'' the border shows again.

Below is a test tex file with three cases. I tried dot and it draw subgraph border in each case.

\documentclass{article}
\usepackage{ctex}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes}
\usepackage{dot2texi}

\begin{document}
% G's subgraph border line is not drawn
\begin{dot2tex}
graph G {
	OneTwo -- ThreeFourFive
	subgraph cluster_T {
		Hello -- World
	}
}
\end{dot2tex}
% H's subgraph border line is not drawn
\begin{dot2tex}
graph H {
	node [shape=box]
	一二 -- 三四五
	subgraph cluster_T {
		你好 -- 世界
	}
}
\end{dot2tex}
% I's subgraph border line is drawn
\begin{dot2tex}
graph I {
	node [shape=box]
	一二 -- 三四
	subgraph cluster_T {
		你好 -- 世界
	}
}
\end{dot2tex}
\end{document}

Bad parsing

Having

digraph example {
    a -> b
    a -> c
    {rank=same; b;c}
}

will generate (dot2tex --preproc -tmath)

digraph example{
    a -> b ;
    subgraph c{
    b;
    c[fixedsize=true,width=0.75,label=" ",texlbl="$c$",height=0.5];

    graph [rank=same];
    }    a -> b ;
    a -> c ;
    a[fixedsize=true,width=0.75,label=" ",texlbl="$a$",height=0.5];
    c[fixedsize=true,width=0.75,label=" ",texlbl="$c$",height=0.5];
    b[fixedsize=true,width=0.75,label=" ",texlbl="$b$",height=0.5];

    graph [d2toutputformat=pgf];
}

Having

digraph example {
    a -> b;
    a -> c;
    {rank=same; b;c};
}

(the same but semicolons)

will produce "correct" (or at least expected)

digraph example{
    a -> b ;
    a -> c ;
    subgraph {
    b;
    c;

    graph [rank=same];
    }    a[fixedsize=true,width=0.75,label=" ",texlbl="$a$",height=0.5];
    c[fixedsize=true,width=0.75,label=" ",texlbl="$c$",height=0.5];
    b[fixedsize=true,width=0.75,label=" ",texlbl="$b$",height=0.5];

    graph [d2toutputformat=pgf];
}

Original GC issue: https://code.google.com/p/dot2tex/issues/detail?id=19

WARNING: Pygments lexer name u'dot' is not known

Hi,
when building the documentation, there are several warnings:

docs/customization_guide.rst:17: WARNING: Pygments lexer name u'dot' is not known                                                                              
docs/customization_guide.rst:47: WARNING: Pygments lexer name u'dot' is not known
docs/customization_guide.rst:80: WARNING: Pygments lexer name u'dot' is not known
docs/customization_guide.rst:127: WARNING: Pygments lexer name u'dot' is not known
docs/customization_guide.rst:178: WARNING: Pygments lexer name u'dot' is not known
docs/customization_guide.rst:228: WARNING: Pygments lexer name u'dot' is not known
docs/customization_guide.rst:261: WARNING: Pygments lexer name u'dot' is not known
docs/tipsandtricks.rst:63: WARNING: Pygments lexer name u'dot' is not known                                                                                    
docs/tipsandtricks.rst:79: WARNING: Pygments lexer name u'dot' is not known
docs/usage_guide.rst:264: WARNING: Pygments lexer name u'dot' is not known                                                                                     
docs/usage_guide.rst:281: WARNING: Pygments lexer name u'dot' is not known
docs/usage_guide.rst:293: WARNING: Pygments lexer name u'dot' is not known
docs/usage_guide.rst:334: WARNING: Pygments lexer name u'dot' is not known
docs/usage_guide.rst:370: WARNING: Pygments lexer name u'dot' is not known
docs/usage_guide.rst:418: WARNING: Pygments lexer name u'dot' is not known
docs/usage_guide.rst:456: WARNING: Pygments lexer name u'dot' is not known

v 2.9.0

How about using standalone?

Hi,

You may not know about the "standalone" LaTeX package. IMHO, it is a better option than preview, as it makes it easy to use a generated file both as a standalone document, and as a figure.

Cheers!

pyparsing version incompatibilities

There is no version of pyparsing specified in the setup.py, which means that Pip or easy_install will just pull the latest version it can find. All 2.0.x versions have incompatibilities with dot2tex, and 1.5.7 sometimes works but there are problems. I have had luck with 1.5.6, e.g.

pip install dot2tex
pip install pyparsing==1.5.6

It would be beneficial to either freeze pyparsing at 1.5.6 in setup.py or add compatibility with newer versions. I can provide more details if necessary, but basically I ran this to figure it out:

pip install pyparsing==x.y.z && dot2tex --debug my-simple-graph.dot

Thanks for creating dot2tex!

KeyError raised by dot2tex in Sage when edge_labels=True

In Sage (with package dot2tex-2.8.7-2.spkg installed) the following commands return a KeyError in the dot2tex.py file :

sage: G = DiGraph()
sage: G.add_edge(3333, 88, 'my_label')
sage: G.set_latex_options(format='dot2tex')
sage: G.set_latex_options(edge_labels=True)
sage: view(G)
ERROR    Failed to process input
Traceback (most recent call last):
  File "/Users/slabbe/Applications/sage-5.2/local/lib/python2.7/site-packages/dot2tex/dot2tex.py", line 2939, in main
    s =  conv.convert(dotdata)
  File "/Users/slabbe/Applications/sage-5.2/local/lib/python2.7/site-packages/dot2tex/dot2tex.py", line 794, in convert
    return self.do_preview_preproc()
  File "/Users/slabbe/Applications/sage-5.2/local/lib/python2.7/site-packages/dot2tex/dot2tex.py", line 1167, in do_preview_preproc
    hp,dp,wt = pp.texdims[name]
KeyError: '3333880'

See GC issue for more details: https://code.google.com/p/dot2tex/issues/detail?id=32

tailtexlbl and headtexlbl not properly handled in base and pstricks converter

DON'T READ THIS ISSUE! (I'm currently researching to understand whether my question is completely foolish)!!!

For example, here it's not clear what it is supposed to do:

        if self.options.get('duplicate', False):
            s += self.start_edge()
            s += self.do_draw_op(drawop, edge, stat)
            s += self.end_edge()
        else:
            s += self.draw_edge(edge)
            s += self.do_drawstring(label_string + " " + tail_label_string + " " + head_label_string, edge) 

Looking for a new maintainer

Is someone interesting in taking over maintenance of dot2tex? I no longer use dot2tex and have kind of lost interest in the project. It is, however, a useful tool that is used by many. It certainly deserves a better fate.

If someone is interested, please contact me at [email protected] or as a comment on this issue.

Strange issues with external dot files (\input)

I think that this is technically a dot2texi issue, but I wasn't sure where to report it, so hopefully this is OK.

I'm having weird behavior with the external files feature. Here is my MWE:

% main.tex
\documentclass{article}
\usepackage[debug]{dot2texi}
\usepackage{tikz} % for dot2texi
\usetikzlibrary{shapes,arrows} % for dot2texi
\begin{document}
\begin{dot2tex}
\input{mygraph.dot}
\end{dot2tex}
\end{document}
// mygraph.dot
digraph mygraph {
        A -> B -> C;
}
pdflatex -shell-escape main.tex

I'm not sure exactly how LaTeX, dot2texi, and dot2tex interact. This works:

\begin{dot2tex}
\\\input{mygraph.dot}
\end{dot2tex}

When you add options, it is even stranger, because now this works:

\begin{dot2tex}[autosize]
\input{mygraph.dot}
\end{dot2tex}

For consistent behavior, you can always pass empty options like:

\begin{dot2tex}[]
\input{mygraph.dot}
\end{dot2tex}

I can work around it, but something seems not right. I wanted to let you know because the example in the texdoc suggests:

\begin{dot2tex}
\input{externalgraph.dot}
\end{dot2tex}

... which does not work.

Tikz format does not support node shape circle

When outputting in Tikz format, nodes specified with shape=circle are rendered as ellipses.
Ex:
digraph minimal {
n [shape = circle, fixedsize = true, label = 11111];
}
through
dot2tex -ftikz minimal.dot
creates
\begin{tikzpicture}[>=latex',line join=bevel,]
%%
\node (n) at (18.0bp,18.0bp) [draw,ellipse] {11111};
%
\end{tikzpicture}

Escaping rules in dot strings are not respected

Hi,

The syntax of dot clearly makes \ special in strings, and therefore to mean a backslash in a string, one must escape it. However, dot2tex does not strip the double-backslashes, and actually processes the string as if it were a raw string (my issue is with d2tdocpreamble). So, for instance, we cannot embed a double-quote as ", since it is then really output as ", without the backslash stripped (included in labels).

Thanks!

fails to parse \input{...}%

dot2tex fails if called from dot2texi with an input file containing \input{...}% instead of \input{...}. The problem is due to failure to parse the % sign. This issue exists in v2.9.0 and in 254cb27.

Details below:

The code:

\documentclass[10pt,xetex]{beamer}

\usepackage[no-math]{fontspec}
\usepackage{xunicode,xltxtra}
\defaultfontfeatures{Mapping=tex-text}

\usepackage[tikz,debug]{dot2texi}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}

\begin{document}

\begin{frame}[fragile]
    \begin{dot2tex}[]
        \input{0.dot}
    \end{dot2tex}
\end{frame}

\end{document}

fails, whereas removing the % from after \input succeeds:

\begin{frame}[fragile]
    \begin{dot2tex}[styleonly,dot,mathmode,scale=0.6]
        \input{0.dot}
    \end{dot2tex}
\end{frame}

The cause I have identified up to now is output \input{0.dot}% to the auxiliary dot file created, then dot2tex fails to parse the line \input{0.dot}% in that file.

The dot2tex.log contents are:

2014-07-17 00:28:31,685 dot2tex INFO ------- Start of run -------
2014-07-17 00:28:31,685 dot2tex INFO Dot2tex version 2.9.0
2014-07-17 00:28:31,697 dot2tex INFO System information:
  Python: sys.version_info(major=2, minor=7, micro=8, releaselevel='final', serial=0) 
  Platform: Darwin-12.5.0-x86_64-i386-64bit
  Pyparsing: 2.0.2
2014-07-17 00:28:31,697 dot2tex INFO dot2tex called with: ['/opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/dot2tex', '--figonly', '-ftikz', '--debug', '-o', 'my_main-dot2tex-fig1.tex', 'my_main-dot2tex-fig1.dot']
2014-07-17 00:28:31,697 dot2tex INFO Program started in mypath/test
2014-07-17 00:28:31,697 dot2tex DEBUG Attempting to read data from my_main-dot2tex-fig1.dot
2014-07-17 00:28:31,698 dot2tex INFO Data read from my_main-dot2tex-fig1.dot
2014-07-17 00:28:31,698 dot2tex DEBUG Input data:
\input{0.dot}%

2014-07-17 00:28:31,699 dot2tex DEBUG Start conversion
2014-07-17 00:28:31,715 dot2tex ERROR Parse error:
\input{0.dot}%
^
Expected 'graph' (at char 0), (line:1, col:1)
2014-07-17 00:28:31,716 dot2tex ERROR Failed to parse graph
Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/dot2tex/dot2tex.py", line 3001, in main
    s = conv.convert(dotdata)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/dot2tex/dot2tex.py", line 752, in convert
    main_graph = parse_dot_data(dotdata)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/dot2tex/dot2tex.py", line 233, in parse_dot_data
    graph = parser.parse_dot_data(dotdata)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/dot2tex/dotparsing.py", line 595, in parse_dot_data
    tokens = self.dotparser.parseString(ndata)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyparsing.py", line 1111, in parseString
    raise exc
ParseException: Expected 'graph' (at char 0), (line:1, col:1)
2014-07-17 00:28:31,719 dot2tex ERROR Failed to parse the input data. Is it a valid dot file?
Try to input xdot data directly. Example:
    dot -Txdot file.dot | dot2tex > file.tex

If this does not work, check that you have an updated version of PyParsing and
Graphviz. Users have reported problems with old versions. You can also run
dot2tex in debug mode using the --debug option:
    dot2tex --debug file.dot
A file dot2tex.log will be written to the current directory with detailed
information useful for debugging.
2014-07-17 00:28:31,719 dot2tex INFO ------- End of run -------

The important line above is:

2014-07-17 00:28:31,715 dot2tex ERROR Parse error:
\input{0.dot}%
^

The error trace is:

ERROR Failed to parse graph Traceback (most recent call last):

File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/dot2tex/dot2tex.py", line 3001, in main s = conv.convert(dotdata)

File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/dot2tex/dot2tex.py", line 752, in convert main_graph = parse_dot_data(dotdata)

File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/dot2tex/dot2tex.py", line 233, in parse_dot_data graph = parser.parse_dot_data(dotdata)

File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/dot2tex/dotparsing.py", line 595, in parse_dot_data tokens = self.dotparser.parseString(ndata)

File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyparsing.py", line 1111, in parseString raise exc ParseException: Expected 'graph' (at char 0), (line:1, col:1)

ERROR Failed to parse the input data. Is it a valid dot file? Try to input xdot data directly. Example: dot -Txdot file.dot | dot2tex > file.tex If this does not work, check that you have an updated version of PyParsing and Graphviz. Users have reported problems with old versions. You can also run dot2tex in debug mode using the --debug option: dot2tex --debug file.dot A file dot2tex.log will be written to the current directory with detailed information useful for debugging.

I am on Mac OS X v10.8.5 using dot2tex v2.9.0 installed with macports (dot2tex port @2.8.7_2).

dot2texi is v2008/05/07 v3.0p1, however the issue exists also in 83a6ddf9c0e0574f7c76f83a98c7d53a84313b8b.

using ortho splines with tikz output doesn't produce orthogonal edges

I'm using graphviz 2.38.0 compiled --with-gts on Ubuntu 14.04.3; when I process the following graph with dot2tex -p --prog fdp -f tikz file_name.dot I obtain the attached figure:

digraph {
    graph [splines=ortho];
    node [shape=rect];
    a;  
    b;  
    c;  
    d;  
    e;  
    f;  
    g;  
    h;  
    c -> e;
    c -> b;
    b -> a;
    e -> a;
    e -> d;
    e -> f;
    c -> d;
    b -> f;
    f -> g;
    g -> h;
    h -> e;
}

I
screenshot_2015-12-01_19-14-00

TeX exits with error "Dimensions too large"

Hello, i just updated to Ubuntu 11.04 and stumbled up on this issues

Ubuntu 11.04 includes these versions:
dot2tex 2.8.7
graphviz 2.26.3
TeX 3.1415926 (TeX Live 2009/Debian)
pgf 2.00-1

After some digging i found that the generated tex-file included coordinate points with very small values (3.5e-18 etc) which seams to be the problem. I guess graphviz has changed something and they seams to output values as %g which uses scientific notation for small and big values.

Im including a patch that forces output to be in non-scientific notation basically by using pythons float function (that supports scientific notation) and then output the number as a %f float.

Patch seams to work fine for me at least. Maybe the conversion can be pushed to the dot parsing stage instead of being in the output stage? also TeX (or pgf?) supports scientific notation so maybe we should just truncate really big och small values instead?

See original GC issue for more details: https://code.google.com/p/dot2tex/issues/detail?id=29

Include manpage

Hi,
for the debian packaging, a manpage was written, but it makes sense to be included upstream (eventually needs updating)

Multiple colors on edges

In graphviz you can create an edge like this: a -- b [color="red:green"] that has one half of it red, the other half green. This is directly transported over a tikz picture which does not understand this.

dot2tex: documentation doesnt build with sphinx 1.8

Hello,
in Debian we just received this bug report, http://bugs.debian.org/918814:

dot2tex fails to build with Sphinx 1.8, currently available in experimental:

  /usr/bin/make -C docs/ html
  make[2]: Entering directory '/<<PKGBUILDDIR>>/docs'
  sphinx-build -b html -d _build/doctrees   . _build/html
  Running Sphinx v1.8.3

  Extension error:
  Could not import extension sphinx.ext.pngmath (exception: No module named pngmath)

The pngmath extension was deprecated in Sphinx 1.4 and has been removed [1]
in Sphinx 1.8. The recommended alternative is sphinx.ext.imgmath [2] which
also has SVG support in addition to PNG.

To me it looks like this extension is unused anyway: there are no “.. math::”
directives or “:math:” roles, and the binary package does not have any
generated PNG images. So maybe this extension can be simply removed from
extensions in conf.py.

[1]: https://github.com/sphinx-doc/sphinx/pull/4702
[2]: https://www.sphinx-doc.org/en/1.8/usage/extensions/math.html

could you have a look at making dot2tex compatible with sphinx 1.8?

thanks!

Handle lowercase color names

Graphviz has a number of predefined color names. The X11 and SVG color schemes are supported by the xcolor LaTeX package, but only if camel case is used.

Examples:

  • limegreen -> LimeGreen
  • sandybrown -> SandyBrown

Graphviz accepts mixed case color strings. Two solutions:

  • document the issue and let the users handle the problem
  • convert lower case color names to camel case

The latter solution requires a mapping between a lower case color name to a correct xcolor name. The mapping could probably be extracted from the xcolor source.

Consider .lnk files when locating GraphViz

Currently dot2tex is enable to find my GraphViz installation on Windows. It cannot find dot.exe in any PATH directory, because there is actualy dot.lnk pointing to dot.exe. Note that if dot2tex just ran dot, it would work (that's what's PATH for).

Support the Graphviz size attribute

Dot2tex currently does not do anything with the size attribute. This is how
Graphviz interprets size:

Maximum width and height of drawing, in inches. If defined and the drawing
is too large, the drawing is uniformly scaled down so that it fits within
the given size.

If size ends in an exclamation point (!), then it is taken to be the
desired size. In this case, if both dimensions of the drawing are less than
size, the drawing is scaled up uniformly until at least one dimension
equals its dimension in size.

A similar behavior could be implemented by scaling the resulting
tikzpicture or pstrics environment.

Original GC issue: https://code.google.com/p/dot2tex/issues/detail?id=7

dot2tex does not support xlabel

This:

digraph G {
    node [shape="circle"];
    forcelabels=true;
    s1 [label="a", xlabel="s1"];
    s1 -> s2 -> s3;
}

Does not show the external label "s1" anywhere.

Handling of oversize edge labels

In the documentation I don't see no clear limitation for edge labels. My intention is to add arbitrary latex into edges of dot graphs. The attached tex source shows that oversize edge labels are not handled correctly (this is possibly related to the behavior of dot2tex to add label=" " to the edge). If this is not a bug or a regression, the issue reports should be used as base for a documentation enhancement.

GC issue: https://code.google.com/p/dot2tex/issues/detail?id=37

Preprocessing interferes multiline edge labels

Preprocessing breaks multiline labels.

digraph {
a -> b [label="line1\nline2\n\nline after an empty line\N"]
}

dot -Txdot /tmp/blah.dot | dot2tex -ftikz --autosize --crop
withpreprocessing3

dot -Txdot /tmp/blah.dot | dot2tex -ftikz --crop
withoutpreprocessing3

TeX compilation in temporary folder makes including local files impossible

hi,
sometimes I have local tex files that I want to include in the
docpreamble (for instance files with tikzstyles for nodes). The problem
is that when using --autosize option, the preprocessing version is
compiled in a temporary folder, so that the included local file is not
found.

Could the all the compilation be done locally instead?

Best,
Misha

\input in tex doesn't work

I tried to use your dot2tex latex-environment with \input. But it doesn't
work. I am using a autogenerated dot-file. It comes from the
python-package sadisplay which visualize database structures.

The output told me to do this:

dot2tex --debug --figonly -ftikz -o x-dot2tex-fig1.tex x-dot2tex-fig1.dot

Doesn't work because of

ERROR    Failed to create xdotdata. Is Graphviz installed?
ERROR    Failed to parse the input data. Is it a valid dot file?
Try to input xdot data directly. Example

    dot -Txdot file.dot | dot2tex > file.tex

Trying this to "input xdot data directly" works fine. So I can not see where the difference is.

I am using Ubuntu 14.04.3 LTS. I installed Python and Python3 packages "pyparser" and "graphviz" from PyPi.

schema.zip

Autosize hangs if a style attribute is added encompassing too many nodes / edges

I can't find a consistent reproducer for this, but dot2tex occasionally hangs on the step 'Opening dot2tex stream main-dot2tex-fig1.dot' when the autosize option is added. This is due to style="..." entries spanning multiple edges / nodes e.g. (node[style="something"]; a; b; c;).

I can avoid the hang by removing the style="..." entries, then gradually re-adding them one-by-one and re-running dot2tex each time. This way I can painstakingly build up the desired style options for the original set of nodes which caused the hang.

Original GC issue: https://code.google.com/p/dot2tex/issues/detail?id=31

Using dot2tex as a module doesn't seem to work

I'm having some strange issues getting dot2tex to work as a module. I've tried both with pip install dot2tex and with a fresh clone of this repository (75e6348), as well as with versions 1.5.7, 2.0.1, and 2.1.0 of pyparsing. None of these combinations seem to work when calling dot2tex from as a module, e.g.,

dot2tex.dot2tex(dotdata)

I've also tried various combinations or arguments and all result in the same error. Everything seems fine when calling dot2tex in stand-alone mode. Furthermore, dot2tex 2.9.0dev, which I got from here, also works fine (but only with pyparsing 1.5.7).

EDIT: I'm not sure what happened exactly, but somehow with all the installs and uninstalls I did, I now cannot make any version of dot2tex work as a module or in stand-alone mode, even with the simplest possible graphs. I'll try later in a virtual environment and see if I can replicate what I was seeing earlier. Something strange is going on and I don't have the bandwidth to track it down fully at the moment. In any case, I'm still seeing the errors below, but with all versions now.

With a fresh install of dot2tex from Pypi and with any version of pyparsing, I get exactly the same error as reported here. I also get that error with a fresh clone of this repo with pyparsing 1.5.7. With a fresh clone of this repo and pyparsing >= 2.0, I get a different error, but the new error seems to be a red herring. The actual failure is in exactly the same place, it's just that the exception is being caught somewhere up the chain and this is leading to a missing file later in the execution.

I debugged it a bit and the real issue arises in a call to

parseImpl( self, instring, loc, doActions=True )

This fails with any input as far as I can tell, but in this case, instring is something very simple:

str: graph G {
rankdir=LR;
layout=dot;
splines=true;
fontsize=44;
0 [shape=rect, label=x_3];
}

Ostensibly, the problem is that self.exprs is

And: {['strict'] {'graph' | 'digraph'} [ID] Suppress:("{") Group:([None]) Suppress:("}")}

and it is the None you see there that eventually causes the problem, but I couldn't manage to understand exactly what that object is or why None appears there. This eventually results in the exception

  File "c:\cygwin64\home\ted\coin\gimpy\src\gimpy\graph.py", line 1692, in display
    tex = dot2tex.dot2tex(self.to_string(), autosize=True, texmode = 'math', template = DOT2TEX_TEMPLATE)
  File "c:\python27\lib\site-packages\dot2tex-2.9.0-py2.7.egg\dot2tex\__init__.py", line 61, in dot2tex
    return d2t.convert_graph(dotsource, **kwargs)
  File "c:\python27\lib\site-packages\dot2tex-2.9.0-py2.7.egg\dot2tex\dot2tex.py", line 3103, in convert_graph
    tex = main(True, dotsource, options)
  File "c:\python27\lib\site-packages\dot2tex-2.9.0-py2.7.egg\dot2tex\dot2tex.py", line 3052, in main
    s = conv.convert(dotdata)
  File "c:\python27\lib\site-packages\dot2tex-2.9.0-py2.7.egg\dot2tex\dot2tex.py", line 760, in convert
    main_graph = parse_dot_data(dotdata)
  File "c:\python27\lib\site-packages\dot2tex-2.9.0-py2.7.egg\dot2tex\dot2tex.py", line 232, in parse_dot_data
    graph = parser.parse_dot_data(dotdata)
  File "c:\python27\lib\site-packages\dot2tex-2.9.0-py2.7.egg\dot2tex\dotparsing.py", line 594, in parse_dot_data
    tokens = self.dotparser.parseString(ndata)
  File "C:\Python27\lib\site-packages\pyparsing.py", line 996, in parseString
    loc, tokens = self._parse( instring, 0 )
  File "C:\Python27\lib\site-packages\pyparsing.py", line 871, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "C:\Python27\lib\site-packages\pyparsing.py", line 2342, in parseImpl
    loc, exprtokens = e._parse( instring, loc, doActions )
  File "C:\Python27\lib\site-packages\pyparsing.py", line 871, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "C:\Python27\lib\site-packages\pyparsing.py", line 2596, in parseImpl
    return self.expr._parse( instring, loc, doActions, callPreParse=False )
  File "C:\Python27\lib\site-packages\pyparsing.py", line 871, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "C:\Python27\lib\site-packages\pyparsing.py", line 2792, in parseImpl
    loc, tokens = self.expr._parse( instring, loc, doActions, callPreParse=False )
AttributeError: 'NoneType' object has no attribute '_parse'

Hope this helps find the problem. I'm happy to help with making it reproducible for you. I can even tell how to install the package I'm using that calls dot2tex and send you a very short script that exhibits the error if that is needed.

I can use 2.9.0dev for now, but would like to be on the official version if possible. Thanks for the nice piece of software by the way!

Node shapes not always drawn in pgf output

So, I have this graph:

      digraph g {
        rankdir=LR;

        node [shape=circle,margin="0,0"];

        URI [label="URI"];
        RDF1 [label="RDF_1"];
        RDF2 [label="RDF_2"];
        RDFp [label="RDF'"];

        URI -> RDFa [label="fetch"];
        RDFa -> RDF [label="parse"];
        RDF -> RDF1 [label="DBPedia"];
        RDF -> RDF2 [label="DBPedia"];
        RDF -> RDFp [label="\cup"];
        RDF1 -> RDFp [label="\cup"];
        RDF2 -> RDFp [label="\cup"];
        RDFp -> Features [label="generate"];
      }

which when run with dot2tex -f pgf does not output any \draw ellipse commands and I get no circles around my nodes when I embed via the dot2texi package.

However, if I just add a random node at the start:

      digraph g {
        rankdir=LR;

        node [shape=circle,margin="0,0"];

        banana;

        URI [label="URI"];
        RDF1 [label="RDF_1"];
        RDF2 [label="RDF_2"];
        RDFp [label="RDF'"];

        URI -> RDFa [label="fetch"];
        RDFa -> RDF [label="parse"];
        RDF -> RDF1 [label="DBPedia"];
        RDF -> RDF2 [label="DBPedia"];
        RDF -> RDFp [label="\cup"];
        RDF1 -> RDFp [label="\cup"];
        RDF2 -> RDFp [label="\cup"];
        RDFp -> Features [label="generate"];
      }

then I do get circles in my document via the dot2texi environment and I do see things like \draw ellipse for each node in the pgf output. Can anyone explain that?

I've got some simpler versions of the diagram earlier in the document that work fine, but there's some strange combination of things in my first file above where all the node shapes just disappear. I've actually seen this a few times with very different diagrams, but this is the first time I've tried dot2tex directly to see the output changes before it even gets to be embedded in my overall LaTeX document.

Does not work with Py 3.4, recursive import in __init__.py

$ pip3 install --user --upgrade dot2tex
$ python3
Python 3.4.3 (default, Oct 14 2015, 20:28:29) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import dot2tex
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/bjorn/.local/lib/python3.4/site-packages/dot2tex/__init__.py", line 36, in <module>
    __version__ = d2t.__version__
AttributeError: 'module' object has no attribute '__version__'

Looking at __init__.py I get confused by the import of dot2tex.

Python 3 support

Dot2tex is a relatively old project and it was also one of my first Python projects. The quality of the code base is therefore not the best :) The code therefore needs to be cleaned up a bit before I will start porting it to Python 3. My plan is to support both 2.7 and 3.x from the same code base.

dot2tex does not like node names with minus signs

Note error for first file; the error doesn't appear with second file.

$ dot2tex -f tikz smallex.dot > file.tex
ERROR    Parse error:
    -4   [_draw_="c 7 -#000000 e 41 18.2 18.4 18.4 ",
 ^
Expected "}" (at char 1149), (line:30, col:2)
ERROR    Failed to parse the input data. Is it a valid dot file?

File contents are below

digraph G {
node [shape="circle"];
"a" -> "b" -> "3" -> "-4" -> "a";
}
digraph G {
node [shape="circle"];
"a" -> "b" -> "3" -> "4" -> "a";
}

fontcolor colors unrelated line and not text

Version 2.8.7+repack-1.1 on Ubuntu 14.04

The fontcolor attribute does not work as expected. It colors a totally unrelated line instead of the text it is supposed to color.

Graph code:

\begin{figure}
  \centering
  \begin{dot2tex}[dot,options=-tmath --autosize --cache]
    digraph {
    u[label="u[3]"];
    w[label="w[1]"];
    x[label="x[2]"];
    u -> w [label="5"];
    w -> x [label="3"];
    x -> w [label="1"];
    u -> x [label="8", fontcolor="red"];
    }
  \end{dot2tex}
\end{figure}

Expected output using dot:

graph

Actual output using dot2tex:

graph-bug

dot2tex does not support label font formatting

The dot languages supports bold/italic/superscript/subscript/underlines text for node labels. I forked the latest dot2tex and apparently it does not support font formatting.

Example graph:

digraph G {
    Foo[label=<<B>Hello</B><SUP>world</SUP>>]
    Bar[label=<<U><I><S>Hel</S>lo</I></U><SUB><B>world</B></SUB>>]

    Foo->Bar
}

Multiline in d2tdocpreamble

Hello,
In using d2tdocpreamble, I found that on some systems, only the first line of a multiline document was included in the resulting tex file.
I am using d2t 2.8.7, on Mac (OS X 10.9) and on debian.
With the following file:

digraph
{
  vcsn_context = "lan<lal_char(abc)>_b"
  rankdir = LR
  d2toptions = "--format tikz --tikzedgelabels --graphstyle=automaton --crop --nominsize --autosize"
  d2tdocpreamble = "    
\usepackage{amssymb}    
\usetikzlibrary{arrows, automata}    
\tikzstyle{automaton}=[shorten >=1pt, pos=.4, >=stealth', initial text=]   
\tikzstyle{named}=[rectangle, rounded corners]    
\tikzstyle{initial}=[initial by arrow]    
\tikzstyle{accepting}=[accepting by arrow]  "
  {
    node [texmode = math, style = state]
    0 [label = "0, 0", style = "named, initial"]
  }
}

on Mac, I have the full preamble, but on linux (debian) I have nothing (well, I have a valid file, but the preamble part is missing).
However, if I put all of the options on the same line:

  d2tdocpreamble = "    \usepackage{amssymb}    \usetikzlibrary{arrows, automata}    \tikzstyle{automaton}=[shorten >=1pt, pos=.4, >=stealth', initial text=]   \tikzstyle{named}=[rectangle, rounded corners]    \tikzstyle{initial}=[initial by arrow]    \tikzstyle{accepting}=[accepting by arrow]  "

I get the line in the preamble.

Use Sphinx for documentation

Dot2tex now uses Sphinx for building the documentation. Earlier versions used pure docutils. There are still some links that don't work after the conversion and the structure should be reviewed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.