我注意到,当我选择将图表的刻度线置于外部时,第一个和最后一个刻度线会变细。有人知道如何解决这个问题吗?这是我使用的代码。下面是生成的图表的屏幕截图。
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[sc]{mathpazo}
\usepackage{amsmath,amssymb,amsfonts,mathrsfs}
\usepackage[amsmath,thmmarks]{ntheorem}
\usepackage{graphicx}
\usepackage{multirow}
\usepackage{geometry}
\usepackage{booktabs,makecell,longtable}
\usepackage{lipsum}
\usepackage{pdfpages}
\usepackage{balance}
\usepackage{lastpage}
\usepackage{amsmath,bm}
\usepackage{textcomp}
\usepackage{subeqnarray}
\usepackage{float}
\usepackage{mathtools}
\usepackage{cite}
\usepackage[export]{adjustbox}
\usepackage{etoolbox}
\usepackage{enumitem}
\usepackage{lmodern}
\usepackage[labelfont=bf,font=sf,labelsep=space]{caption}
\usepackage{mathpazo}
\usepackage[nottoc,notlot,notlof]{tocbibind}
\usepackage{pgfplots}
\usepackage{hyperref}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\pgfkeys{/pgf/number format/.cd,1000 sep={}}
\newcommand{\myfont}{\fontfamily{cmss}\selectfont}% used with mathpazo
\DeclareMathOperator{\Tr}{Tr}
\setcounter{tocdepth}{2}
\pgfplotsset{compat=1.5.1}
\pgfplotsset{label style={font=\Large},
tick label style={font=\Large}}
\pgfplotsset{error bars/.cd,
x dir=both, x explicit,
y dir=both, y explicit,
}
\pgfplotsset{/pgfplots/error bars/error bar style={semithick,black}}
%\pgfplotsset{/pgfplots/label shift={0pt}}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}[
axis line style=semithick,
width=9cm,
height=7cm,
only marks,
%mark size=3pt,
%legend image post style={mark options={scale=1.3,fill=white,line width=0.8pt}},
legend style={at={(0.95,0.3)},draw=none},
legend cell align={right},
x tick style={black,semithick},
x label/.style=
{at={(ticklabel cs:0.5)},anchor=near ticklabel},
xlabel={{$\epsilon_n$} [{\myfont -}]},
xmin=0,xmax=1,
xtick={0,0.5,...,1},
xtick pos=bottom,
%minor x tick num=1,
xtick align=outside,
%xminorgrids=true,
every y tick/.style={black,semithick},
y label style=
{at={(ticklabel cs:0.5)},anchor=near ticklabel},
ylabel={{$\sigma_n$} [{\myfont MPa}]},
ymin=0,ymax=150,
ytick={0,50,...,150},
ytick pos=left,
%minor y tick num=1,
ytick align=outside,
%yminorgrids=true,
]
\addplot [sharp plot,red,very thick,mark=*,mark options={scale=2,blue,fill=white}]
coordinates{
(0.2,40)
(0.4,70)
(0.6,100)
(0.8,130)
};
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}
答案1
欢迎来到 TeX.SE!这是因为 50% 的外部刻度被剪掉了。如果你稍微扩大一点限制,这种效果就会消失。所以你可能想添加
enable tick line clipping=false
到你的选项axis
。这是一个完整的 MWE,其中我剥离了不直接相关的包。
\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{pgfplots}
\pgfkeys{/pgf/number format/.cd,1000 sep={}}
\newcommand{\myfont}{\fontfamily{cmss}\selectfont}% used with mathpazo
\pgfplotsset{compat=1.5.1}
\pgfplotsset{label style={font=\Large},
tick label style={font=\Large}}
\pgfplotsset{error bars/.cd,
x dir=both, x explicit,
y dir=both, y explicit,
}
\pgfplotsset{/pgfplots/error bars/error bar style={semithick,black}}
%\pgfplotsset{/pgfplots/label shift={0pt}}
\begin{document}
\begin{tikzpicture}
\begin{axis}[enable tick line clipping=false,
axis line style=semithick,
width=9cm,
height=7cm,
only marks,
%mark size=3pt,
%legend image post style={mark options={scale=1.3,fill=white,line width=0.8pt}},
legend style={at={(0.95,0.3)},draw=none},
legend cell align={right},
xtick align=outside,
ytick align=outside,
major x tick style={black,semithick},
x label/.style=
{at={(ticklabel cs:0.5)},anchor=near ticklabel},
xlabel={{$\epsilon_n$} [{\myfont -}]},
xmin=0,xmax=1,
xtick={0,0.5,1},
xtick pos=bottom,
%minor x tick num=1,
%xminorgrids=true,
every y tick/.append style={black,semithick},
y label style=
{at={(ticklabel cs:0.5)},anchor=near ticklabel},
ylabel={{$\sigma_n$} [{\myfont MPa}]},
ymin=0,ymax=150,
ytick={0,50,...,150},
ytick pos=left,
%minor y tick num=1,
%yminorgrids=true,
]
\addplot [sharp plot,red,very thick,mark=*,mark options={scale=2,blue,fill=white}]
coordinates{
(0.2,40)
(0.4,70)
(0.6,100)
(0.8,130)
};
\end{axis}
\end{tikzpicture}
\end{document}
另一个选择是使用enlargelimits={abs=0.4pt}
。