Page attribute not applied

Hello everyone,

Thank you for this great library, it is very useful!!

I had Graphviz v2.30 and it worked fine, but I had some issues with some attributes that were supposed to be fixed in the newer versions.

So I updated it (I am using a Mac under Mavericks, so I dowloaded the 2.36 version as a package for convenient installation). But now, the page attribute is not taken into account when plotting the graphs into pdf (it was when I used v2.30)...

I use graphviz as a C library and neato to plot it. I tried various sizes and it does not change.

I need to have a fixed page size so that I can make a video out of the graphs I plot, where the distances and sizes are preserved, in order to see their evolutions (and not use the pictures where the graphs are filling the page).

How can I fix this, please? I searched for the page attribute, but cannot find much (on this site, I cannot differentiate the "page" attribute from just "page") 

Thank you!

Re: Page attribute not applied

Sorry for the difficulties. I'm not sure if any of us will be able to fix this or work on it soon.

It would be a good idea to try generating the layouts in another format (like PNG, or particularly the native PS driver) and see if the same problems occur.  It is possible that the Mac OSX Quartz driver imposes its own page size limitation (perhaps in the interest of not allocating an unreasonable amount of memory - compare all the complaints about the cairo driver just falling over with memory access violations when the layout is very large and malloc() runs out of space).  It is possible that the Quartz driver might have changed between releases of Graphviz as well, though offhand I wouldn't expect it.  You could also try your code on a Linux machine with the cairopango version of the PDF driver, to see if that makes any difference.

I don't think issues with pagesize and "pos" are related.

I don't think ! has any meaning in the page size argument but I've been wrong before.

I thought the ! notation was being deprecated but Emden knows more about that.

Stephen North






Hi Stephan, Thank you for

Hi Stephan,

Thank you for replying too!

I tried with jpg, png and svg, the same occurs: changes in the attribute in the C code do not change the output. And using the command line neato does not work here, as expected by erg's answer (the "page" attribute only working with .ps format). Also, outputting to jpg (or jpeg if it matters) gives a white page...
Is the Mac Quartz used in generating the file?

Yes, the root/pos and page attribute issues are not related, I just wanted to mention them both, sorry for the confusion.

I also tried without the !, same result

What confuses me is that it worked in 2.30 but not in 2.36... I may try to downgrade my version.

Can you please file a bug

Can you please file a bug report, or post an input file and the command you are using to generate output? It's much easier for us to track something down if we have some data to work with. Thanks.

Hi erg,   Thank you for

Hi erg,


Thank you for replying. How do I generate a bug report?

Sorry if I am not helping here, I am not sure what you are asking me...

So I actually create nodes and edges from a data file (several time series) after many computations, so I may not put the input here.

But basically, I create one node per column of the data file (total of 200+ nodes), one edge between some of those nodes (a Minimum Spanning Tree). So I set some cluster and node attributes (label, its size, color and position, plus the shape of the nodes), then create the edges and set their length (computed before).

Also, I wanted to have a node (the first one) always at the center of the graph, so that everything would be relative to this center. I tried to pin and pos it to 0,0 : agsafeset(nodes[0], "pos", "0,0"); (also tried with "0,0!"), but I think it doesn't work? I also tried the "root" attribute of the graph and also of the node nodes[0]...

And I also set the page attribute of the graph g (actually I set it before the clusters and nodes): agsafeset(g, "page", "8000,5000!", "");
    agsafeset(g, "center", "true", ""); (so that the graph is always at the center of the page and I can see its evolution in all directions, instead of left/right and top/bottom aligning).

Finally, I layout and render using those instructions:

    gvLayout (gvc, g, "neato");
    char FileName[30];
    sprintf(FileName, "MSTs/MST3D%d.pdf",dates[k]);
    gvRenderFilename (gvc, g, "pdf", FileName);
    gvFreeLayout(gvc, g);

If there is a solution to somewhat keep the relative positions of all nodes (or at least clusters) for each graph I plot, it would be really nice... (I haven't seen anything like this in the documentation?)

Thank you again for the help

You can file a bug report at

You can file a bug report at

You've given me more information, but I still don't know what you mean by the page attribute not working. (By the way, the units for page are inches, so 8000 and 5000 are pretty large. And page only works for postscript output.)

Since you can't send the code, replace your call to gvLayout...gvRenderFilename with agwrite(g, stdout) and capture your graph in text form. You can then run neato on that and see what output you are getting. If there are still problems, post this graph with a description of what is wrong. Or submit this information to a bug report. Thanks.

Thank you again for your

Thank you again for your help, erg.

I am filling out a bug report.

The last paragraph summarises the issue.

Yes, the point of this hugh size was to see whether I was not underestimating the size of the initial graph and to emphasize the effect if it would be displayed.

I tried outputting to .ps file with:

sprintf(FileName, "");
gvRenderFilename (gvc, g, "ps", FileName);

and also in command line: neato -Tps -o

but when I open the .ps file with Mac's Preview, it says "error, could not convert to pdf". I tried with Adobe Photoshop and Illustrator, they also give me errors (maybe there is an issue with my installation?). I used different settings of the "page" attribute (from "6,4" to this "8000,5000") and all give the same errors. I want .pdf or .ps to have vectorised files (much smaller files and no pixellisation issues) that can be used in most other softwares.


I tried to output it to a text file, but my graph generates a 2k-line file. So I tried with a simple graph and code:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cgraph.h>
#include <cdt.h>
#include <gvc.h>

int main()
    Agraph_t *g;
    Agnode_t *nodes[5];
    Agedge_t *e[4];
    GVC_t* gvc = gvContext();
    g = agopen("Graphe", Agstrictundirected, NULL);
    agsafeset(g, "page", "8000,5000!", "");
    agsafeset(g, "center", "true", "");
    int j;
    char nomNoeud[10];
    for (j = 0; j < 5; j++)
        sprintf(nomNoeud,"Node %d", j+1);
        nodes[j] = agnode(g, nomNoeud, TRUE);
    agsafeset(nodes[0], "root", "true", "");
    agsafeset(nodes[0], "pin", "true", "");
    agsafeset(nodes[0], "pos", "0,0!", "");
    e[0] = agedge(g, nodes[0], nodes[1], 0, 1);
    agsafeset(e[0], "len", "5", "");
    e[1] = agedge(g, nodes[0], nodes[2], 0, 1);
    agsafeset(e[1], "len", "3", "");
    e[2] = agedge(g, nodes[3], nodes[1], 0, 1);
    agsafeset(e[2], "len", "1", "");
    e[3] = agedge(g, nodes[4], nodes[1], 0, 1);
    agsafeset(e[3], "len", "10", "");
    gvLayout (gvc, g, "neato");
    char FileName[30];
    sprintf(FileName, "Test.pdf");
    gvRenderFilename (gvc, g, "pdf", FileName);
    //agwrite(g, stdout);
    gvFreeLayout(gvc, g);

And writing the output graph to a file gives:

strict graph Graphe {
    graph [center=true,
    node [label="\N"];
    "Node 1"     [pin=true,
    "Node 1" -- "Node 2"     [len=5];
    "Node 1" -- "Node 3"     [len=3];
    "Node 4" -- "Node 2"     [len=1];
    "Node 5" -- "Node 2"     [len=10];

So this time, it worked using the command line with small settings for "page" ("8,5")... But then the page is too small and the graph is split into several pages. So when I increase the size, it works, but the whole graph is not in the pages, for example with "24,15" or even "16,10"...

So here, the "page" attribute changes the output file, but in the C code, I get the same .pdf output file (.ps do not open with my applications...), with whichever setting I use for this attribute (while with v2.30, it did change, even with .pdf)...

Recent comments