如何在轴原点显示“0”值?
\documentclass[border=2mm]{standalone}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{pgfplots}
\usepackage{siunitx}
\pgfplotsset{compat=1.11}
\begin{document}
\begin{tikzpicture}
\begin{axis}[grid style=dashed,grid=both,ymin=0,ymax=70,xmax=0.35,xmin=0,
minor tick num=1,axis lines = middle,xlabel=$x_1$,ylabel=T\;$(\si{\celsius})$,
x label style={at={(axis description cs:1.1,0.03)},anchor=north},
y label style={at={(axis description cs:0,1.0)},anchor=south}, x tick label style={
/pgf/number format/.cd,
fixed relative,
},
]
\addplot+[color=red,mark=*,mark options={draw=red,fill=green},smooth]
coordinates {
(0.05,31.9)(0.10,30.1)(0.20,35.8)(0.31,65.4)
};
\end{axis}
\end{tikzpicture}
\end{document}
答案1
像这样?
\documentclass[border=2mm]{standalone}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{pgfplots}
\usepackage{siunitx}
\pgfplotsset{compat=1.16} % <--- i suggest you to upgrade pgfplots
\begin{document}
\begin{tikzpicture}
\begin{axis}[
grid, grid style=dashed,
ymin=0,ymax=70,
extra y ticks={0}, % <---
xmax=0.35,xmin=0,
extra x ticks={0}, % <---
minor tick num=1,
axis lines = middle,
set layers, % <---
axis on top, % <---
xlabel=$x_1$,ylabel=T\;$(\si{\celsius})$,
x label style={at={(1,0)},right},
y label style={at={(0,1)},above},
x tick label style={/pgf/number format/.cd,
fixed relative,
},
]
\addplot+[color=red,mark=*,mark options={draw=red,fill=green},smooth]
coordinates {
(0.05,31.9)(0.10,30.1)(0.20,35.8)(0.31,65.4)
};
\end{axis}
\end{tikzpicture}
\end{document}