Intervall der horizontalen Achse

Intervall der horizontalen Achse

Ich möchte der X-Achse für das angehängte Diagramm ein benutzerdefiniertes Intervall hinzufügen. Es sollte bei 20 beginnen und dann um 5 erhöht werden. Zum Beispiel 20, 25, 30, … 50. Eine ähnliche Frage wurde bereits gestellt, aber sie wurde ohne Antwort geschlossen. Vielen Dank im Voraus. Mein Code ist unten dargestellt.

\begin{figure}[!h]
\begin{centering}
%\begin{adjustwidth}{-1.5cm}{}
\begin{tikzpicture}  
\begin{axis}[
    footnotesize,
    xbar, 
    width=11.0cm, height=4.5cm, 
    enlarge y limits=0.01,
    enlargelimits=0.07,  
    %xlabel={\#participants},
    symbolic y coords={Al, Stor, Pro, Ser, Domain, Services},
    ytick=data,
    nodes near coords, nodes near coords align={horizontal},
    every node near coord/.append style={font=\footnotesize},
]
    \addplot coordinates {
    (48,Services) (27,Domain) (26,Ser) (25,Pro) (23,Stor) (37,All)};
\end{axis}
\end{tikzpicture}  
\caption{Design}
%\end{adjustwidth}
\label{fig:SQ21}
\end{centering}
\end{figure}

Bildbeschreibung hier eingeben

Antwort1

Wie bereits im Kommentar unter der Frage erwähnt, fügen Sie den Optionen einfach xmin=20und hinzu , um das gewünschte Ergebnis zu erzielen.xtick distance=5axis

% used PGFPlots v1.17
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
    \begin{axis}[
        footnotesize,
        xbar,
        width=11.0cm, height=4.5cm,
        % ---------------------------------------------------------------------
        % added
        xmin=20,
        xtick distance=5,
        % ---------------------------------------------------------------------
        enlarge y limits=0.01,
        enlargelimits=0.07,
        symbolic y coords={All, Stor, Pro, Ser, Domain, Services},
        ytick=data,
        nodes near coords,
        nodes near coords align={horizontal},
        every node near coord/.append style={font=\footnotesize},
    ]
        \addplot coordinates {
            (48,Services) (27,Domain) (26,Ser) (25,Pro) (23,Stor) (37,All)
        };
    \end{axis}
\end{tikzpicture}
\end{document}

Bild, das das Ergebnis des obigen Codes zeigt

verwandte Informationen