Latex pgfplots loglogaxis scaling

时间:2016-01-29 05:42:11

标签: latex scale axis

我在Latex中有loglog轴,我想改变y轴的缩放,如下所示:y-Axis应该用以下符号进行签名:5 * 10e1,10e2,2 * 10e2但是这个数字应该用整数表示: 50,100,200。图形的网格应该保持不变。

\documentclass[12pt]{scrartcl}

\usepackage[paperwidth=18cm, paperheight=12cm]{geometry}

%Digrammzeug
\usepackage{pgfplots}


\begin{document}

\thispagestyle{empty} % um die Seitenzahl zu endfernen
\newgeometry{left=0.1cm, right=0.1cm, top=0.1cm, bottom=0.1cm}


\begin{figure}
   \centering
   \begin{tikzpicture}
   \begin{loglogaxis}[
   axis x line=bottom,
   axis y line=left,
   ymax = 2.1*10^2,
   xlabel=N (log),
  ylabel=$ \mathrm{S_a} $ in MPa (log),
  every axis x label/.style={
     at={(ticklabel* cs:1.05)},
     anchor=west,
  },
  every axis y label/.style={
     at={(ticklabel* cs:1.05)},
     anchor=south,
  },
  ytick={10, 100},  
  scale=1.6,
  grid=both,
  tick align=outside,
  tickpos=left,
  ]

  %Lasth 1
  \node at (axis cs: 10^5.25,10^2.193) {Lasthorizont I};

  %Lasth 2
  \node at (axis cs: 10^6.2,10^1.955) {Lasthorizont II};

  %Lasth 1 - 2 Gerade
  \addplot[black, mark=square*] coordinates { (50966, 155.74) (477468, 90.16)};

  %Lasth 2 - N_D Gerade
  \addplot[black,no marks] coordinates { (477468, 90.16) (2.5*10^6, 60.16677272)};

  %Dauerfestigkeit
  \addplot[black, mark=square*, mark indices={1}] coordinates { (2.5*10^6, 60.16677272) (10^7, 60.16677272)};
  \addplot[black, dotted, no marks] coordinates { (2.5*10^6, 60.16677272) (10^7.3, 60.16677272) };  
  \addplot[black, dashed] coordinates { (10^4, 60.16677272) (2.5*10^6, 60.16677272) };

  %Beschriftung
  \addplot[dashed] coordinates { (2.5*10^6, 60.16677272) (2.5*10^6, 10^1.7)};
  \node at (axis cs: 10^5.4,10^1.85) {Zeitfestigkeit};
  \node at (axis cs: 10^5.4,10^1.74) {Dauerfestigkeit};
  \node at (axis cs: 10^6.85,10^1.73) {$ N_D=2,5\cdot10^6 $};
  \node at (axis cs: 10^4.4,10^1.Cool {$ S_{aD} \approx $ 60.17};

  %Lasthorizont III
  \addplot[black, thick, mark=x] coordinates {(180000, 117.49)};
  \node at (axis cs: 10^5.8, 10^2.07) {Lasthorizont III};

  \end{loglogaxis}
  \end{tikzpicture}
 \end{figure}


\end{document}

1 个答案:

答案 0 :(得分:0)

我意识到很久以前就已经问过这个问题,并且属于tex.stackexchange.com,但对于那些正在寻找解决方案并且没有答案的人来说这个问题;我找到了一个可行的解决方案,我将在下面分享。 我在@ Jake的onetwo答案中找到了您问题的答案。

您正在寻找的内容(我认为)是axis环境与xmode=logymode=log的组合。为了获得标记的轴,您将其与log ticks with fixed point组合。这是一个默认的pgf选项,它将修改两个轴。

由于您只要求特定的y轴刻度,我使用此pgfplotsset的新定义将其用于下面的工作示例。顺便说一下,我用.Cool评论了这一行,因为我对此并不熟悉,这会引起我的问​​题,请随意取消评论。

   \begin{tikzpicture}

   \pgfplotsset{
  log x ticks with fixed point/.style={
      xticklabel={
        \pgfkeys{/pgf/fpu=true}
        \pgfmathparse{exp(\tick)}%
        \pgfmathprintnumber[fixed relative, precision=3]{\pgfmathresult}
        \pgfkeys{/pgf/fpu=false}
      }
  },
  log y ticks with fixed point/.style={
      yticklabel={
        \pgfkeys{/pgf/fpu=true}
        \pgfmathparse{exp(\tick)}%
        \pgfmathprintnumber[fixed relative, precision=3]{\pgfmathresult}
        \pgfkeys{/pgf/fpu=false}
      }
  }
}

   \begin{axis}
   [xmode=log,
   ymode=log,
   log x ticks with fixed point,
   axis x line=bottom,
   axis y line=left,
   ymax = 2.1*10^2,
   xlabel=N (log),
  ylabel=$ \mathrm{S_a} $ in MPa (log),
  every axis x label/.style={
     at={(ticklabel* cs:1.05)},
     anchor=west,
  },
  every axis y label/.style={
     at={(ticklabel* cs:1.05)},
     anchor=south,
  },
  ytick={10, 100},  
  scale=1.6,
  grid=both,
  tick align=outside,
  tickpos=left,
  ]

  %Lasth 1
  \node at (axis cs: 10^5.25,10^2.193) {Lasthorizont I};

  %Lasth 2
  \node at (axis cs: 10^6.2,10^1.955) {Lasthorizont II};

  %Lasth 1 - 2 Gerade
  \addplot[black, mark=square*] coordinates { (50966, 155.74) (477468, 90.16)};

  %Lasth 2 - N_D Gerade
  \addplot[black,no marks] coordinates { (477468, 90.16) (2.5*10^6, 60.16677272)};

  %Dauerfestigkeit
  \addplot[black, mark=square*, mark indices={1}] coordinates { (2.5*10^6, 60.16677272) (10^7, 60.16677272)};
  \addplot[black, dotted, no marks] coordinates { (2.5*10^6, 60.16677272) (10^7.3, 60.16677272) };  
  \addplot[black, dashed] coordinates { (10^4, 60.16677272) (2.5*10^6, 60.16677272) };

  %Beschriftung
  \addplot[dashed] coordinates { (2.5*10^6, 60.16677272) (2.5*10^6, 10^1.7)};
  \node at (axis cs: 10^5.4,10^1.85) {Zeitfestigkeit};
  \node at (axis cs: 10^5.4,10^1.74) {Dauerfestigkeit};
  \node at (axis cs: 10^6.85,10^1.73) {$ N_D=2,5\cdot10^6 $};
  %\node at (axis cs: 10^4.4,10^1.Cool {$ S_{aD} \approx $ 60.17};

  %Lasthorizont III
  \addplot[black, thick, mark=x] coordinates {(180000, 117.49)};
  \node at (axis cs: 10^5.8, 10^2.07) {Lasthorizont III};

  \end{axis}
  \end{tikzpicture}

这提供了下图:

Which provides the following