11
$\begingroup$

Bug introduced in 10.0 and fixed in 11.2
Problem is due to a BezierCurve bug.


I don't understand why the following does not work:

Export["graph.pdf", Graph[{1 <-> 1, 1 <-> 2}, EdgeShapeFunction -> "Line", 
        EdgeStyle -> {Black}, VertexStyle -> Black, VertexSize -> .05]]

It evaluates fine, but the resulting PDF only seems to show half the loop at vertex 1.

The problem seems to be with EdgeShapeFunction: it displays correctly in Mathematica, but does not export correctly to PDF

$\endgroup$
6
  • 1
    $\begingroup$ I should probably add that the problem seems to be with EdgeShapeFunction: it displays correctly in Mathematica, but does not export correctly to PDF. $\endgroup$
    – Steve D
    Oct 6, 2014 at 16:49
  • 3
    $\begingroup$ I have reported this as a bug to Wolfram Technical Support. A support case with the identification [CASE:1762814] was created. $\endgroup$
    – rhermans
    Oct 7, 2014 at 10:01
  • $\begingroup$ @rhermans and Steve, can either of you (or anyone else reading) confirm that this bug existed in 10.0.0? $\endgroup$
    – Mr.Wizard
    Oct 14, 2014 at 19:19
  • 1
    $\begingroup$ @Mr.Wizard, sorry no, I don't have 10.0.0 any more, and Wolfram Technical Support didn't comment further when they replied. 'Replicated and an incident report was forwarded to developers', was pretty much all they said. $\endgroup$
    – rhermans
    Oct 14, 2014 at 19:32
  • 3
    $\begingroup$ I can reproduce this bug up through 11.1.1. In 11.2, it is no longer reproducible. $\endgroup$
    – John Fultz
    Apr 16, 2018 at 22:36

2 Answers 2

11
$\begingroup$

I can reproduce your problem (Win7 64, M10.0.1). Same problem if you try with PDF or EPS format.

Graph with bug

When actually your graph should look like this

Graph[{1 <-> 1, 1 <-> 2}, EdgeShapeFunction -> "Line",  EdgeStyle -> {Black}, VertexStyle -> Black, VertexSize -> .05]

Mathematica graphics

It looks like this is a bug, but there is an easy way around if you can afford to have a raster image instead of a vector. The graph can be transformed into a bitmap using Rasterize

Export["graph.pdf", 
 Rasterize[
  Graph[{1 <-> 1, 1 <-> 2}, EdgeShapeFunction -> "Line", 
   EdgeStyle -> {Black}, VertexStyle -> Black, VertexSize -> .05], 
  ImageSize -> 2^10]]

Graph rasterized

Until this is fixed if you need vector format, you can use SVG, which works fine.

EDIT:

or, you can remove the option EdgeShapeFunction->"Line" as pointed out by @Steve_D, i.e yourself. Still, this is a bug.

enter image description here

$\endgroup$
2
  • 3
    $\begingroup$ You can actually fix the problem by removing the EdgeShapeFunction->"Line". $\endgroup$
    – Steve D
    Oct 6, 2014 at 21:45
  • $\begingroup$ On my system (OS X 10.10.4), it doesn't even display correctly in the notebook, so rasterization doesn't help either. I traced the problem back to a BezierCurve bug. $\endgroup$
    – Szabolcs
    Jul 19, 2015 at 9:57
6
$\begingroup$

On my system (OS X 10.10.4) it doesn't even display correctly on-screen. This means that rasterization doesn't help.

I can confirm the problem in 10.0.2, 10.1.0 and 10.2.0. The problem doesn't exist in 9.0.1.

enter image description here

We can trace back this problem to a BezierCurve bug.

gr = 
  Show@Graph[{1 <-> 1, 1 <-> 2}, EdgeShapeFunction -> "Line", 
    EdgeStyle -> {Black}, VertexStyle -> Black, VertexSize -> .05];

bc = First@Cases[gr, _BezierCurve, Infinity]
(* BezierCurve[{{1., 0.}, {1.08848, 0.190784}, {1.28736, 0.24718}, {1.41453, 0.188223}, {1.41453, -0.188223}, {1.28736, -0.24718}, {1.08848, -0.190784}, {1., 0.}}, SplineDegree -> 7] *)

Graphics[{bc, Red, PointSize[Large], Point[pts], Black, Dashed, Line[pts]}]

Note that only half of the curve is displayed. This only happens with SplineDegree -> 7 in this case.

Mathematica graphics

BezierFunction doesn't suffer from the same problem:

ParametricPlot[BezierFunction[pts, SplineDegree -> 7][t] // Evaluate, {t, 0, 1}]

Mathematica graphics

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.