Wie kann ich das Raster richtig erstellen?

Wie kann ich das Raster richtig erstellen?

Ich versuche, das Raster in meine Grafik einzufügen, und habe das folgende Problem. Der Rasterstil muss Hilfslinien und gestrichelte Linien sein. Ich weiß, wie das geht, aber das Problem besteht weiterhin darin, das Raster richtig einzufügen.

Hier ist der Code, den ich verwende.

 \documentclass[a4paper,10pt]{article}
    \usepackage{pgfplots}
    \usepackage{filecontents}
    \usepackage{lmodern}
    \pgfplotsset{compat=1.3}
    \usepgfplotslibrary{groupplots}

    \begin{filecontents*}{dataCL.csv}
        x, y
        10, 0.7 
        15, 0.6
        20, 0.5
    \end{filecontents*}
    \begin{filecontents*}{dataCD.csv}
        x, y
        10, 0.4
        15, 0.3
        20, 0.2
    \end{filecontents*}

    \begin{document}


\pgfkeys{
   /pgf/number format/.cd, 
      set decimal separator={,{\!}},
      set thousands separator={}
}
\pgfplotsset{
   every axis/.append style = {
      line width = 0.5pt,
      tick style = {line width=1pt},
      grid style={dashed}
   }
}
\begin{tikzpicture}
    % provide shared options here with pgfplotsset:
    \pgfplotsset{
        height=6cm, width=9cm,
        no markers=major
    }
    % this is the leftmost y axis (y2)
    \begin{axis}[
        xmin=0,xmax=1,%--- CF
        xshift=0cm,%-- CF
        width=2cm,
        hide x axis, 
        axis y line*=left,
        ymin=0, ymax=1.2,
        ytick = {0,0.24,0.48,...,1.2},
        ylabel={$C_l$}
        ]
   \end{axis}
   \begin{axis}[
        xmin=0, xmax=10,
        xshift=7cm,%-- CF
        width=2cm,
        hide x axis,
        axis y line*=right,
        ymin=0, ymax=0.5,
        ytick = {0,0.1,0.2,...,0.5},
        ylabel={$C_D$}
    ]
    \end{axis}
     \begin{axis}[
        height=2cm, 
        xmin=0, xmax=25,
        ymin=0, ymax=1.2,
        minor ytick = {0,5,10,...,25},
        axis x line*=bottom,
        hide y axis,
        xlabel={$\alpha$}
    ]
    \end{axis}
    \begin{axis}[
     xmin = 0, xmax=25,
     ymin = 0, ymax=1.2,
     hide x axis,
     hide y axis,
     ]
     \addplot+ [mark = none] table [col sep=comma, x=x, y=y]{dataCL.csv};
    \end{axis}
    \begin{axis}[
     xmin = 0, xmax=25,
     ymin = 0, ymax=0.5,
     hide x axis,
     hide y axis,
     ]
     \addplot+ [mark = none] table [col sep=comma, x=x, y=y]{dataCD.csv};
    \end{axis}
    \begin{axis}[grid]

    \end{axis}


 \end{tikzpicture}

\end{document}

Ich kann den Maßstab und das Raster nicht gleichzeitig richtig zeichnen

Antwort1

Ich finde einen Weg, das zu tun.

\documentclass[a4paper,10pt]{article}
    \usepackage{pgfplots}
    \usepackage{filecontents}
    \usepackage{lmodern}
    \pgfplotsset{compat=1.3}
    \usepgfplotslibrary{groupplots}

    \begin{filecontents*}{dataCL.csv}
        x, y
        10, 0.7 
        15, 0.6
        20, 0.5
    \end{filecontents*}
    \begin{filecontents*}{dataCD.csv}
        x, y
        10, 0.4
        15, 0.3
        20, 0.2
    \end{filecontents*}

    \begin{document}


\pgfkeys{
   /pgf/number format/.cd, 
      set decimal separator={,{\!}},
      set thousands separator={}
}
\pgfplotsset{
   every axis/.append style = {
      line width = 0.5pt,
      tick style = {line width=1pt},
      grid style={dashed}
   }
}
\begin{tikzpicture}
    % provide shared options here with pgfplotsset:
    \pgfplotsset{
        height=6cm, width=9cm,
        no markers=major
    }
    % this is the leftmost y axis (y2)
    \begin{axis}[ymajorgrids,
        xmin=0,xmax=1,%--- CF
       % xshift=0cm,%-- CF
        %width=2cm,
        hide x axis, 
        axis y line*=left,
        ymin=0, ymax=1.2,
        ytick = {0,0.24,0.48,...,1.2},
        ylabel={$C_l$}
        ]
   \end{axis}
   \begin{axis}[
        xmin=0, xmax=10,
        xshift=7cm,%-- CF
        width=2cm,
        hide x axis,
        axis y line*=right,
        ymin=0, ymax=0.5,
        ytick = {0,0.1,0.2,...,0.5},
        ylabel={$C_D$}
    ]
    \end{axis}
     \begin{axis}[xmajorgrids,
        height=6cm, 
        xmin=0, xmax=25,
        ymin=0, ymax=1.2,
        minor ytick = {0,5,10,...,25},
        axis x line*=bottom,
        hide y axis,
        xlabel={$\alpha$}
    ]
    \end{axis}
    \begin{axis}[
     xmin = 0, xmax=25,
     ymin = 0, ymax=1.2,
     hide x axis,
     hide y axis,
     ]
     \addplot+ [mark = none] table [col sep=comma, x=x, y=y]{dataCL.csv};
    \end{axis}
    \begin{axis}[
     xmin = 0, xmax=25,
     ymin = 0, ymax=0.5,
     hide x axis,
     hide y axis,
     ]
     \addplot+ [mark = none] table [col sep=comma, x=x, y=y]{dataCD.csv};
    \end{axis}
 \end{tikzpicture}
\end{document}

verwandte Informationen