1

I'm trying to get a 3dplot with only xy plane, without z axis and zx and zy planes. To be clear, this is the best result i've got:

plot from attached code

and this is what i'd like to obtain:

enter image description here

Here's the code:

\begin{tikzpicture}
    \begin{axis}[
            title=Hello plot,
            hide z axis,
            grid=major,
            axis lines*=left,
            ]
        \addplot3[
            surf,
            mesh/ordering=y varies,
            %mesh/rows=10,
            %mesh/cols=53,
            %scatter,
            ] table {
week    year    pax
0       2017    0
0       2018    77

1       2017    89
1       2018    0

2       2017    49
2       2018    25

3       2017    76
3       2018    53

4       2017    20
4       2018    46

5       2017    47
5       2018    35

6       2017    28
6       2018    74

7       2017    123
7       2018    116

8       2017    70
8       2018    14

9       2017    78
9       2018    74

10      2017    205
10      2018    64 
};
    \end{axis}
\end{tikzpicture}

Suggestion?

  • Welcome! You could just draw the lines by hand. Please add the preamble to your code. – user121799 Mar 7 at 22:58
  • \pgfplotsinvokeforeach{2,4,...,8} {\draw[thin,gray] (#1,2017)--(#1,2018);} \pgfplotsinvokeforeach{2017.5,2018} {\draw[thin,gray] (0,#1)--(10,#1);} – user121799 Mar 7 at 23:03
  • @marmot thanks for your reply! I've not added preamble, because it's just a \usepackage{pgfplots}, nothing strange What you mean with draw the lines by hand? I'd like to remove them... And to be more specific: the main problem it's the vertical space, not removed when i remove the z axis – Benci Mar 7 at 23:05
1

What I meant is this:

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}

\begin{tikzpicture}
    \begin{axis}[
            title=Hello plot,
            hide z axis,
            %grid=major,
            axis lines*=left,
            ]
        \pgfplotsinvokeforeach{2,4,...,8}
        {\draw[thin,gray] (#1,2017)--(#1,2018);}    
        \pgfplotsinvokeforeach{2017.5,2018}
        {\draw[thin,gray] (0,#1)--(10,#1);} 
        \addplot3[
            surf,
            mesh/ordering=y varies,
            %mesh/rows=10,
            %mesh/cols=53,
            %scatter,
            ] table {
week    year    pax
0       2017    0
0       2018    77

1       2017    89
1       2018    0

2       2017    49
2       2018    25

3       2017    76
3       2018    53

4       2017    20
4       2018    46

5       2017    47
5       2018    35

6       2017    28
6       2018    74

7       2017    123
7       2018    116

8       2017    70
8       2018    14

9       2017    78
9       2018    74

10      2017    205
10      2018    64 
};
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

  • Ok, maybe a viable workaround. But there's still too much vertical space (the z axis is simply non shown, but the space is here). – Benci Mar 8 at 10:28

Your Answer

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

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