Latex pgfplots对数轴缩放

Latex pgfplots对数轴缩放,latex,scale,axis,Latex,Scale,Axis,我有Latex中的loglog轴,我想改变y轴的比例,如下所示:y轴应该用:5*10e1,10e2,2*10e2签名,但这个数字应该用整数表示,比如:50,100,200。图表的网格应保持不变 \documentclass[12pt]{scrartcl} \usepackage[paperwidth=18cm, paperheight=12cm]{geometry} %Digrammzeug \usepackage{pgfplots} \begin{document} \thispag

我有Latex中的loglog轴,我想改变y轴的比例,如下所示:y轴应该用: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}

我意识到这个问题很久以前就被问到了,并且属于我们,但是对于那些正在寻找解决方案的人来说,他们发现这个问题没有答案;我找到了一个可行的解决方案,我将在下面与大家分享。 我在@Jake's and answers中找到了你问题的答案


我认为,您正在寻找的是
axis
环境与
xmode=log
ymode=log
的组合。为了得到标记的轴,您可以将其与带有固定点的日志刻度相结合。这是一个默认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}
这提供了下图:


我意识到这个问题很久以前就被问过了,属于我们,但对于那些正在寻找解决方案的人来说,这个问题却没有答案;我找到了一个可行的解决方案,我将在下面与大家分享。 我在@Jake's and answers中找到了你问题的答案


我认为,您正在寻找的是
axis
环境与
xmode=log
ymode=log
的组合。为了得到标记的轴,您可以将其与带有固定点的日志刻度相结合。这是一个默认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}
这提供了下图: