Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I export graphics to PDF using:

Export["/path/figure.pdf", plotname]

It gives me more than enough quality for PDFLatex. But somehow, some exported plots have 'extra' lines (it doesn't happen when I export to PNG/JPG for example):

image showing plot with extra lines

It doesn't happen to all exported plots, and in Mathematica itself, the plot looks correct: no extra lines visible.

The ListPlot is more than just a ListPlot (it uses external data to make five different ListPlots and is then showed in one plot using Show), but the other plots made in the same way are perfectly fine, so I guess it has nothing to do with how the plot has been generated. Sorry I am sich a n00b, I don't know how to add all this code. So again, I have shared it online: [link to notebook code].2

The funny thing is, I have 'built' three of these plots, only the one in the shared code, gives this problem. This plot is the 'middle' plot, i.e., there has been a plot made before, then I clear the counters, and start again.

FYI: You can't run the code, because it needs external data. The external data are many CSV files containing 9 rows of each a text string and a numeric value. I am using Mathematica on Ubuntu 13.04.

Thinking it might be some 'leftover' information, I've tried to clear all parameters/variables, quit the kernel (local), quit Mathematica as a whole. But the problem isn't solved.

I hope someone here knows what might be going on. I prefer not to change all my figures to a different format. If there is a best format for PDFLatex, then of course I will reconsider, at least for the future. But I expect PDF to fit perfectly with PDFLatex...

share|improve this question

closed as unclear what you're asking by Jens, R. M. Aug 2 '13 at 2:06

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

Could you provide a link to the image here in comments? Then, someone will edit it into the question for you. As it is I don't think I've seen this phenomenon before and have trouble imagining what it looks like. Code to generate the problematic figure would also be very valuable (more or less mandatory, even). – Oleksandr R. May 2 '13 at 16:13
I'll do my best, it's loads of code, so I'll see if I can get the important part, thanks. The link to the image is the following: – Ampi Severe May 2 '13 at 16:48
BTW Welcome to! – Sjoerd C. de Vries May 2 '13 at 17:42
Could it be some extra points/lines due to your original data? Maybe they are out of PlotRange in Mathematica, but are shown in PDF? Could you give an example code (including the minimal data) to reproduce this? – Silvia May 2 '13 at 19:49
Which Mathematica version are you using? There already is one new bug in pdf export introduced in v.9. – Alexey Popkov May 2 '13 at 20:13

A very simple workaround is to save your image as JPG or PNG. It is important to choose a good ImageResolution as Export Option.

This sounds like dirty workaround but If you have very many points in you vector-based pdf-file you will end up with a very large file. Then a rasterized image is better. In your document (especially in print), no difference can be seen.

Hope this helps. Anyway it is pretty difficult to help, as you do not provide runnable code.

share|improve this answer
I understand it's difficult. I'll have a look at the ImageResolution posibilities, thanks! – Ampi Severe May 3 '13 at 13:33
If this answer help you to solve the problem, please consider accepting it. – Philipp May 16 '13 at 16:29
I understand that, but the problem is that exporting to JPG or PNG doesn't answer my question. As I state in the question, with JPG or PNG I never had this problem, I only have it with PDF. As I have all my figures currently with PDF in this particular document, I would like to be able to export this figure to PDF too, as the PDF and JPG/PNG aren't exactly the same. If I solve the PDF problem, I don't need to export all my other figures again. Exporting to JPG/PNG is helpful for new new documents. Anyhow, as I cannot give code to actually run, I don't think this will be answered soon. – Ampi Severe May 18 '13 at 13:49
If I see that the JPG/PNG with a correct ImageResolution look the same as the PDF, than my problem is indeed solved and I will of course accept your answer! I'll have a look at this later today or tomorrow. – Ampi Severe May 18 '13 at 13:51
I can't get the ImageResolution working. Also when I export to JPG or PNG the font of the axes label change and the graphs are thinner than in the pdf. I eliminated the extra lines in the PDF with GIMP. Next time I'll redecide which format to use. Thanks everyone for trying! – Ampi Severe May 22 '13 at 9:16

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