PGFPlot 等距座標

PGFPlot 等距座標

我怎麼能繪製出所提供的 x 座標在視覺上以相同距離分開的圖。

所以不應該是 0 500 1000 1500 2000

0 10 20 50 100 200 ...

第二件事是ylabel和y座標重疊,如何將標籤移得更遠?

\begin{tikzpicture}
    \begin{axis}[
        xlabel=Züge(\#),
        ylabel=Zeit(s)]
    \addplot[color=red,mark=x] coordinates {
        (10,25)
        (20,12)
        (50,33)
        (100,1800)
        (200,1800)
        (500,1800)
        (1000,509)
        (2000,1514)
    };
    \end{axis}
\end{tikzpicture}

答案1

我會將對數刻度與使用者定義的刻度和刻度標籤結合使用。

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
  \begin{semilogxaxis}[
    xlabel=Züge(\#),
    ylabel=Zeit(s),
    xtick=\empty,
    extra x ticks={10,20,50,100,200,500,1000,2000},
    extra x tick labels={10,20,50,100,200,500,1000,2000}]
    \addplot[color=red,mark=x] coordinates {
      (10,25)
      (20,12)
      (50,33)
      (100,1800)
      (200,1800)
      (500,1800)
      (1000,509)
      (2000,1514)
    };
  \end{semilogxaxis}
\end{tikzpicture}
\end{document}

在此輸入影像描述

相關內容