【问题标题】:Latex pgfplots loglogaxis scalingLatex pgfplots loglogaxis 缩放
【发布时间】:2016-01-29 05:42:10
【问题描述】:

我在 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}

【问题讨论】:

    标签: latex scale axis


    【解决方案1】:

    我知道这个问题很久以前就被问过了,属于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}
    

    这提供了下图:

    【讨论】:

      猜你喜欢
      • 2021-12-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-31
      • 1970-01-01
      • 2010-11-26
      相关资源
      最近更新 更多