我第一次用 LaTeX 绘制图表……真的很难。
我的尝试:
\documentclass{scrartcl}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
scale only axis,
axis lines=middle,
xlabel={Concentration [ppm]},
ylabel={Absorption},
xmin=-4, xmax=8,
ymin=0, ymax=0.5,
xtick={-4,-2,0,2,4,6,8},
ytick={0.1,0.2,0.3,0.4,0.5},
legend pos=north west,
ymajorgrids=true,
grid=major,
]
\addplot[
color=blue,
mark=square,
]
coordinates {
(-2.13,0)(0,0.1127)(2,0.2165)(4,0.3177)(6,0.4193)
};
\end{axis}
\end{tikzpicture}
\end{document}
但它应该看起来像这样
请注意,我实际上是想在 LaTeX 的方格纸上绘制校准图形曲线。
非常感谢!
答案1
像这样:
变化:
grid style={line width=.1pt, draw=orange!50},
使网格变为橙色,线宽为 0.1 pt
minor x tick num={9}, minor y tick num={9},
为 x 轴和 y 轴制作 9 个小刻度。
设置grid=both,
xlabel style={at={(ticklabel* cs:1)},anchor=north west},
锚点 x 轴标签右下方。
ylabel style={at={(ticklabel* cs:1)},anchor=south west}
将 y 轴标签锚定在左上角。
编辑:
我添加了major grid style={line width=.2pt, draw=orange},
一个更深的主网格,使它看起来更像一张刻度纸。
\documentclass{scrartcl}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[grid style={line width=.1pt, draw=orange!30},major grid style={line width=.2pt, draw=orange},
minor x tick num={9},
minor y tick num={9},
scale only axis,
axis lines=middle,
xlabel={Concentration [ppm]},
ylabel={Absorption},
xmin=-4, xmax=8,
ymin=0, ymax=0.5,
xtick={-4,-2,0,2,4,6,8},
ytick={0,0.1,0.2,0.3,0.4,0.5},
legend pos=north west,
ymajorgrids=true,
grid=both,
xlabel style={at={(ticklabel* cs:1)},anchor=north west,xshift=-3.2cm,yshift=-0.6cm},
ylabel style={at={(ticklabel* cs:1)},anchor=south east,yshift=-0.8cm,xshift=-0.3cm}
]
\addplot[
color=blue,
mark=square,
]
coordinates {
(-2.13,0)(0,0.1127)(2,0.2165)(4,0.3177)(6,0.4193)
};
\end{axis}
\end{tikzpicture}
\end{document}