勾选标签问题

勾选标签问题

我想知道如何将 x 轴和 y 轴刻度更改为:

  1. 在 y 轴上添加英制单位并保持公制单位(双单位)
  2. 强制 x 轴上的每个标签都采用十进制形式(无科学计数法形式)并具有固定的小数位数(例如,轴应为 0.00、0.05、0.10、0.20 等)

下面是我的代码,可能有点乱,不过希望还是能实现上面两个目的。

我感谢任何人提供的帮助。

\documentclass{article}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}


\begin{axis}[
    legend style={at={(1.4,0)},draw=none,anchor= south, legend columns=1, font=\small,text width=3in, minimum height=0.2in}, 
    ymin=0,ymax=700,
    xlabel = Strain,
    every axis x label/.style=
        {at={(ticklabel cs:0.5)},anchor=near ticklabel},
    ylabel = Stress (MPa),
    every axis y label/.style=
        {at={(ticklabel cs:0.5)},rotate=90,anchor=near ticklabel},    
    xmin=0, xmax=0.35,
    xtick={0.0,0.05,...,0.35},
xticklabel style={/pgf/number format/.cd,fixed zerofill,precision=3},
 yticklabel style={/pgf/number format/.cd,fixed zerofill,precision=2},
width=0.75\linewidth,
height=0.58\linewidth,
font=\small,    
axis x line=bottom,
axis y line=left,
]
\begin{scope}[
      every pin edge/.style={<-,>=latex, mark size=3pt},
      every pin/.append style={font=\small}
    ]

%Idea Connection 5% Strain Limit (True Material)
\addlegendentry{Engineering Stress Strain}
\addplot [name path=engineering,color = red,ultra thick, mark size=3pt,,mark options={fill=gray} opacity = 0.75] table [y=Y1, x=X1]{2021latex_source/Experiment/Stress-Strain/Engineering_Stress-Strain};
        %\node[coordinate,pin={[pin distance=1 in,pin edge={gray,thick}]320:{39.85 kip, 5\% PE} } ]
            %at (axis cs:0.041,39.848) {};

 \addlegendentry{True Stress Strain}
\addplot [name path=true,color = blue,ultra thick, mark size=3pt,,mark options={fill=gray} opacity = 0.75] table [y=Y2, x=X2]{2021latex_source/Experiment/Stress-Strain/True_Stress-Strain};

\addlegendentry{(\ref{Callister, Stress}) $\sigma_T=\sigma_{e}*(1+\epsilon_{eng})$}
    \addplot+[black,mark = none,mark size=3pt,mark options={fill=black}, only marks,opacity=0] coordinates {(-0.012,500)};
\addlegendentry{{(\ref{Callister, Strain}) $\epsilon_T=\ln*(1+\epsilon_{eng})$}}
    \addplot+[black,mark = none,mark size=3pt,mark options={fill=black}, only marks,opacity=0] coordinates {(-0.012,500)};
 
 %bracket for Zone A (before necking)
 %\draw [pen colour={blue},decorate, decoration={calligraphic brace,amplitude=25pt,raise=1pt}] (axis cs:0,85) -- (axis cs:0.06,85) node[pos=0.5,above=25pt,black]{Zone 1 (Before Necking)};
 
\node[inner sep=0pt] (whitehead) at (axis cs:0.12,15)
    {\includegraphics[width=.2\textwidth]{2021latex_source/Experiment/Stress-Strain/Engineering_Stress-Strain}};
    

  
\addplot+[black,mark = *,mark size=3pt,mark options={fill=black}, only marks] coordinates {(0.012
,439) (0.2,512) (0.182322,614.400000) (0.29,350)};

    
%Labels-----------------------------
    
    \node[inner sep=0pt] (whitehead) at (axis cs:0.12,650)
    {\small{Eq. (\ref{Callister, Stress}), (\ref{Callister, Strain})}};

        \node[coordinate,pin={[pin distance=0.35 in,pin edge={gray,thick}]30:{Necking Point} } ]
            at (axis cs:0.2,512) {};

    \node[inner sep=0pt] (whitehead) at (axis cs:0.03,400)
    {\small{A}};

    \node[inner sep=0pt] (whitehead) at (axis cs:0.18,450)
    {\small{B}};
    
    \node[inner sep=0pt] (whitehead) at (axis cs:0.21,615)
    {\small{B'}};    

    \node[inner sep=0pt] (whitehead) at (axis cs:0.31,350)
    {\small{C}}; 

    \node[inner sep=0pt] (whitehead) at (axis cs:0.1,160)
    {\small{Hardening Region}};    

    \addplot [<->, black, dashed, thick] coordinates {(0.012,439)  (0.012,0)};
    \addplot [<->, black,dashed, thick] coordinates {(0.2,512)  (0.2,0)};
    \addplot [<->, black, thick] coordinates {(0.012,100)  (0.2,100)};

    \addplot [<->, black, dashed, thick] coordinates {(0.29,350)  (0.29,0)};
    \addplot [<->, black, thick] coordinates {(0.2,100)  (0.29,100)};
    
    \node[inner sep=0pt] (whitehead) at (axis cs:0.245,160)
    {\small{Necking}}; 



\end{scope}
\end{axis}
\end{tikzpicture}
\end{center}
\caption{True Stress-Strain Conversion, Region ii}
\label{True Stress-Strain Conversion, Region ii}
\end{figure}

\end{document}

'''

答案1

像那样 ?

\documentclass{article}
\usepackage{pgfplots}
\usepackage{siunitx}

\begin{document}
    \begin{tikzpicture}
        \pgfplotsset{
            width=0.75\linewidth,
            height=0.58\linewidth,
            xmin=0, xmax=0.35,
        }
        \begin{axis}[
            xtick={0.0,0.05,...,0.35},
            ymin=0,ymax=700, ytick={0,200,400,600},
            every axis x label/.style={at={(ticklabel cs:0.5)},anchor=near ticklabel},
            every axis y label/.style={at={(ticklabel cs:0.5)},rotate=90,anchor=near ticklabel},
            font=\small,
            xticklabel style={
                /pgf/number format/.cd,
                    fixed,
                    fixed zerofill,
                    precision=3,
                /tikz/.cd
            },
            yticklabel style={
                /pgf/number format/.cd,
                    fixed,
                    fixed zerofill,
                    precision=2,
                /tikz/.cd
            },
            axis x line=bottom,
            axis y line=left,
            xlabel = {Strain},
            ylabel = {Stress (\unit{\mega\pascal})},
            legend style={at={(1.4,0)},draw=none,anchor= south, legend columns=1, font=\small,text width=3in, minimum height=0.2in}, 
            ]
        \end{axis}
        \begin{axis}[
            axis x line=none,
            axis y line=right,
            ymin=0,ymax=101.5, ytick={0,29,58.01,87.02},
            ylabel={Stress (\unit{\kilo psi})},
            y label style={, anchor=north}
            ]
        \end{axis}
    \end{tikzpicture}

\end{document}

在此处输入图片描述

  • 优先使用siunitx包进行单元编写。
  • 在发送之前尝试编译你的 MWE。
  • 英制单位不应该用于科学...(这是个人观点)

相关内容