看起来 x 轴和 y 轴的维度有点偏离

看起来 x 轴和 y 轴的维度有点偏离

为什么 x 轴和 y 轴的比例不一样,看起来 y 轴稍微小一点。

\documentclass[border=1 cm]{standalone}
\usepackage{amsmath}
\usepackage{pgfplots,tikz}
\usepackage{bm}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{arrows,tikzmark,patterns}

\pgfplotsset{compat=1.18}


\begin{document}
    
    
    \begin{tikzpicture}[declare function={%
            funk(\x)=10^(\x);
        }]
        % let both axes use the same layers
        \pgfplotsset{set layers}        
        \begin{axis}[                                       
            axis x line=center,
            axis y line=center,
            xtick={-4,-2,...,14},
            ytick={-4,-2,...,14},
            xmin=-4,xmax=14,ymin=-4,ymax=14, 
            every inner x axis line/.append style={-triangle 45},
            every inner y axis line/.append style={-triangle 45},
            yticklabel style = {font=\tiny,xshift=0.5ex},
            xticklabel style = {font=\tiny,yshift=0.5ex},
            grid=both,minor tick num=1              
            ]       
            
            
            
            
            %Graf for fuktionen
        
            \draw (13,1.9) node [scale=0.7,yshift=-0.25ex] {$f(x)$};
            
            \addplot[smooth,thick,samples=1000, domain=-1:14, blue,y filter/.expression={y<-2?\pgfkeysvalueof{/pgfplots/ymin}:y}] {log10(x)};   
            
            \addplot[smooth,thick,samples=100, domain=-10:2, blue] {10^(x)};    
            
            \addplot[dashed,thick,samples=100, domain=-10:14, black] {x};   
            
            %Punkter    
            \draw[line width=1pt, color=black,fill=black] (1,0) circle (1.2pt);
        
            \draw[line width=1pt, color=black,fill=black] (0,1) circle (1.2pt);
            
            \draw[line width=1pt, color=black,fill=black] (10,1) circle (1.2pt);
            
            \draw[line width=1pt, color=black,fill=black] (1,10) circle (1.2pt);
            
            %Linjer
            
            \draw[dashed,thick,black] (1,10) -- (10,1); 
            
            
        \end{axis}  
        
    \end{tikzpicture}


\end{document}

图片 在此处输入图片描述

当我使用轴相等时,我得到了这张图片

在此处输入图片描述

答案1

您可以使用axis equal image=true而不是axis equal。引用 pgfplots 文档:

类似axis equal,但轴限值也将保持不变


\documentclass[border=1 cm]{standalone}
\usepackage{amsmath}
\usepackage{pgfplots,tikz}
\usepackage{bm}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{arrows,tikzmark,patterns}

\pgfplotsset{compat=1.18}


\begin{document}
    
    
    \begin{tikzpicture}[declare function={%
            funk(\x)=10^(\x);
        }]
        % let both axes use the same layers
        \pgfplotsset{set layers}        
        \begin{axis}[                                       
            axis x line=center,
            axis y line=center,
            xtick={-4,-2,...,14},
            ytick={-4,-2,...,14},
            xmin=-4,xmax=14,ymin=-4,ymax=14, 
            every inner x axis line/.append style={-triangle 45},
            every inner y axis line/.append style={-triangle 45},
            yticklabel style = {font=\tiny,xshift=0.5ex},
            xticklabel style = {font=\tiny,yshift=0.5ex},
            grid=both,minor tick num=1,
            axis equal image=true              
            ]       
            
            
            
            
            %Graf for fuktionen
        
            \draw (13,1.9) node [scale=0.7,yshift=-0.25ex] {$f(x)$};
            
            \addplot[smooth,thick,samples=1000, domain=-1:14, blue,y filter/.expression={y<-2?\pgfkeysvalueof{/pgfplots/ymin}:y}] {log10(x)};   
            
            \addplot[smooth,thick,samples=100, domain=-10:2, blue] {10^(x)};    
            
            \addplot[dashed,thick,samples=100, domain=-10:14, black] {x};   
            
            %Punkter    
            \draw[line width=1pt, color=black,fill=black] (1,0) circle (1.2pt);
        
            \draw[line width=1pt, color=black,fill=black] (0,1) circle (1.2pt);
            
            \draw[line width=1pt, color=black,fill=black] (10,1) circle (1.2pt);
            
            \draw[line width=1pt, color=black,fill=black] (1,10) circle (1.2pt);
            
            %Linjer
            
            \draw[dashed,thick,black] (1,10) -- (10,1); 
            
            
        \end{axis}  
        
    \end{tikzpicture}


\end{document}

在此处输入图片描述

相关内容