自定义 Pgfplots

自定义 Pgfplots

如何在不同位置显示轴标签?如何在轴原点显示数字 0?

\documentclass[11pt]{article} 
\usepackage[utf8]{inputenc} 
\usepackage{textcomp} 
\usepackage[italian]{babel} 
\usepackage[   
a4paper,   margin=15mm,   bindingoffset=2mm,   heightrounded, 
]
{geometry} 
\usepackage{amssymb} 
\usepackage{amsmath} 
\usepackage{mathtools} 
\usepackage{float} 
\usepackage{pgfplots} 
\usepackage{xcolor} 
\usepgfplotslibrary{external} 
\tikzexternalize 
\definecolor{arancione}{HTML}{E26200}

\begin{document}

\begin{tikzpicture} 
 \begin{axis}[  
    width=12cm,
    axis y line=center, 
    axis x line=middle,
     xmin=0, xmax=21, 
     ymin=0, ymax=15, 
     xlabel=ml,
     ylabel=pH,
     xmajorgrids=true,
     ymajorgrids=true,
    grid style=dashed,
    ytick={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14},
    xtick={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},
    ]
    \addplot[color=arancione,mark=o] coordinates {
    (1,3.61)(2,3.99)(3,4.16)(4,4.33)(5,4.52)(6,4.64)(7,4.80)(8,4.91)(9,5.06)(10,5.24)(10.5,5.38)(11,5.49)(11.5,5.67)(12,5.82)(12.2,5.99)(12.4,6.09)(12.6,6.46)(12.8,6.98)(13,7.35)(13.2,10.92)(13.4,11.22)(13.6,11.37)(13.8,11.50)(14,11.58)
    (14.5,11.78)(15,11.83)(15.5,11.91)(16,11.97)(17,12.08)(18,12.13)(19,12.18)(20,12.22)
    }; 
\end{axis} 
\end{tikzpicture} 
\end{document}

在此处输入图片描述

答案1

您可以删除轴线命令。这似乎可以解决您的两个问题:

\documentclass[11pt]{article} 
\usepackage[utf8]{inputenc} 
\usepackage{textcomp} 
\usepackage[italian]{babel} 
\usepackage[   
a4paper,   margin=15mm,   bindingoffset=2mm,   heightrounded, 
]
{geometry} 
\usepackage{amssymb} 
\usepackage{amsmath} 
\usepackage{mathtools} 
\usepackage{float} 
\usepackage{pgfplots} 
\usepackage{xcolor} 
%\usepgfplotslibrary{external} 
%\tikzexternalize 
%\definecolor{arancione}{HTML}{E26200}

\begin{document}

    \begin{tikzpicture} 
    \begin{axis}[  
    width=12cm,
%   axis y line=center, 
%   axis x line=middle,
    xmin=0, xmax=21, 
    ymin=0, ymax=15, 
    xlabel=ml,
    ylabel=pH,
    xmajorgrids=true,
    ymajorgrids=true,
    grid style=dashed,
    ytick={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14},
    xtick={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},
    ]
    \addplot[color=blue,mark=o] coordinates {
        (1,3.61)(2,3.99)(3,4.16)(4,4.33)(5,4.52)(6,4.64)(7,4.80)(8,4.91)(9,5.06)(10,5.24)(10.5,5.38)(11,5.49)(11.5,5.67)(12,5.82)(12.2,5.99)(12.4,6.09)(12.6,6.46)(12.8,6.98)(13,7.35)(13.2,10.92)(13.4,11.22)(13.6,11.37)(13.8,11.50)(14,11.58)
        (14.5,11.78)(15,11.83)(15.5,11.91)(16,11.97)(17,12.08)(18,12.13)(19,12.18)(20,12.22)
    }; 
    \end{axis} 
    \end{tikzpicture} 
\end{document}

在此处输入图片描述

相关内容