I have used the answer from another post, but the generated PDF seems to be corrupted using the suggested code. This post refers to question: Fill pattern for time series with bounds (tikz pgfplots)

An answer suggested using the following code:


temps   y_h y_h__inf    y_h__sup    y_f y_f__inf    y_f__sup    y_dd

100     0.0000      0.0000      0.0000      0.0001      0.0001      0.0001      0.0001
101     0.1713      0.0000      0.3445      0.3445      0.3445      0.3445      0.3445
102     0.5007      0.0000      0.5633      0.5633      0.5633      0.5633      0.5633
103     0.6984      0.5633      0.7615      0.7513      0.6691      0.7615      0.7615
104     0.7664      0.0000      0.8981      0.8544      0.5633      0.8981      0.8981
105     0.8766      0.7615      0.9388      0.9157      0.8395      0.9660      0.9660
106     0.9225      0.6691      0.9916      0.9317      0.7615      0.9916      0.9916
107     0.9334      0.8395      0.9916      0.9016      0.6691      0.9962      0.9986
108     0.8463      0.5633      0.9986      0.8914      0.6691      0.9916      0.9999
109     0.8725      0.4521      0.9999      0.9112      0.7615      0.9916      1.0000
110     0.8306      0.0000      1.0000      0.8820      0.6691      0.9962      1.0000



% y_h confidence interval
\addplot [stack plots=y, fill=none, draw=none, forget plot]   table [x=temps, y=y_h__inf]   {\table} \closedcycle;
\addplot [stack plots=y, pattern=north west lines,pattern color=red!50, opacity=0.4, draw opacity=0, area legend]   table [x=temps, y expr=\thisrow{y_h__sup}-\thisrow{y_h__inf}]   {\table} \closedcycle;
% subtract the upper bound so our stack is back at zero
\addplot [stack plots=y, stack dir=minus, forget plot, draw=none] table [x=temps, y=y_h__sup] {\table};

% y_f confidence interval
\addplot [stack plots=y, fill=none, draw=none, forget plot]   table [x=temps, y=y_f__inf]   {\table} \closedcycle;
\addplot [stack plots=y, , pattern=north east lines,pattern color=blue!50, opacity=0.4, draw opacity=0, area legend]   table [x=temps, y expr=\thisrow{y_f__sup}-\thisrow{y_f__inf}]   {\table} \closedcycle;

% the line plots (y_h and y_f)
\addplot [stack plots=false, very thick,red]  table [x=temps, y=y_h]   {\table};
\addplot [stack plots=false, very thick,blue]  table [x=temps, y=y_f]   {\table};
\addplot [stack plots=false, very thick,green]  table [x=temps, y=y_dd]   {\table}; % smooth


However, there is some weird "behavior": I use TexMaker to compile my tex files. When using the code you suggested and compiling in TexMaker, the application-build-in viewer shows nothing (only a blank space). Now, opening the created PDF with Adobe Viewer, the graph looks correct. Opening it with Nitro PDF gives very weird colors and fillings, that change all the time when zooming in or out.

The code must somehow lead to a corrupted PDF file.

The following command


is also not accepted. TexMaker responds with:

! Package pgfkeys Error: Choice '1.12' unknown in choice key '/pgfplots/compat/ anchors'. I am going to ignore this key."

Any ideas what may be the problem?

  • 2
    compat=1.12 doesn't work because you have an older version of pgfplots. You may try updating your tex distribution. The other problem may be an viewer artefact. – user11232 Oct 26 '15 at 5:02
  • Dear Harish Kumar: I appreciate your answers. Unfortunately, nothing worked out so far: 1) I re-installed pgfplots via the MikTex updater, and the error for "\pgfplotsset{compat=1.12}" remains. 2) Regarding the viewing problem of the pdf, I don't understand what you mean. Even compiling the code and displaying it in the build-in viewer of TexMaker takes more time when using pattern instead of fill. The built-in viewer doesn't show the plot at all within the figure. Are there any other work-arounds without using pattern? – San Oct 27 '15 at 6:50
  • Try updating as admin too. (if you already did as user). And viewer artefact depends on the viewer. Try sumatrapdf and report the outcome please. – user11232 Oct 27 '15 at 6:57
  • I updated as admin, but no change. With sumatrapdf, the results are shown correctly. If adobe reader does not have the right artefacts to correctly view the PDF, then I better generate an image that does not require particular artefacts. Is there another way to define the fill pattern? – San Oct 28 '15 at 15:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.