我已经创建了一个 tikzpicture 但许多坐标重叠。
示例代码:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\definecolor{bblue}{HTML}{4F81BD}
\definecolor{rred}{HTML}{C0504D}
\definecolor{ggreen}{HTML}{008000}
\definecolor{ppurple}{HTML}{9F4C7C}
\definecolor{mustard}{HTML}{cc9900}
\newcommand{\avtwo}{\texttt{2AVG}}
\newcommand{\avplus}{\texttt{AVG + AVG/2}}
\newcommand{\av}{\texttt{AVG}}
\newcommand{\avgdivt}{\texttt{AVG/2}}
\newcommand{\avgdivf}{\texttt{AVG/4}}
\newcommand{\avgdive}{\texttt{AVG/8}}
\title{Graphs}
\date{}
\begin{document}
\maketitle
\begin{figure*}
\centering
\begin{tikzpicture}[scale=0.7]
\begin{axis}[
ylabel={y axis},
xlabel = {Thresholds},
width = 1.8*\textwidth,
height = 18cm,
scaled y ticks = false,
y tick label style={font=\large},
y label style={font=\Large},
x tick label style={font=\large},
x label style={font=\Large},
y label style={at={(axis description cs:-0.001,.5)},anchor=south},
symbolic x coords={\avtwo, \avplus, \av, \avgdivt, \avgdivf, \avgdive},
xtick=data,
x tick label style={},
nodes near coords align={vertical},
legend cell align=right,
legend style={font=\Large,at={(0.173,1.12)},
anchor=north,legend columns=-1}
]
\addplot [only marks,mark=square*,mark size=4pt,color=red,mark options={solid},solid] coordinates{
(\avtwo,98.83) (\avplus,98.48) (\av,97.84) (\avgdivt,96.25) (\avgdivf,94.04) (\avgdive,90.92)
};
\addplot [only marks,mark=*, mark size=4pt,color=bblue,solid] coordinates{
(\avtwo,98.71) (\avplus,98.16) (\av,97.33) (\avgdivt,96.07) (\avgdivf,94.69) (\avgdive,92.53)
};
\addplot [only marks,mark=asterisk, mark size=5pt,color=ggreen,solid] coordinates{
(\avtwo,90.53) (\avplus,87.82) (\av,82.43) (\avgdivt,69.49) (\avgdivf,54.42) (\avgdive,40.93)
};
\addplot [only marks,mark=triangle*, mark size=5pt,color=ppurple,solid] coordinates{
(\avtwo,92.34) (\avplus,90.2) (\av,86.01) (\avgdivt,75.71) (\avgdivf,64.1) (\avgdive,53.96)
};
\addplot [only marks,mark=diamond*, mark size=5pt,color=mustard,solid] coordinates{
(\avtwo,90.33) (\avplus,87.58) (\av,82.31) (\avgdivt,69.84) (\avgdivf,58.12) (\avgdive,48.12)
};
\legend{DP,TR,SP,TR\_SP,SP\_TR}
\end{axis}
\end{tikzpicture}
\end{figure*}
\end{document}
产生的输出是:
是否可以缩放 y 轴以避免重叠?
答案1
可以安装用户转换。我无法确定这在特定情况下是否有很大帮助。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\definecolor{bblue}{HTML}{4F81BD}
\definecolor{rred}{HTML}{C0504D}
\definecolor{ggreen}{HTML}{008000}
\definecolor{ppurple}{HTML}{9F4C7C}
\definecolor{mustard}{HTML}{cc9900}
\newcommand{\avtwo}{\texttt{2AVG}}
\newcommand{\avplus}{\texttt{AVG + AVG/2}}
\newcommand{\av}{\texttt{AVG}}
\newcommand{\avgdivt}{\texttt{AVG/2}}
\newcommand{\avgdivf}{\texttt{AVG/4}}
\newcommand{\avgdive}{\texttt{AVG/8}}
\title{Graphs}
\date{}
\begin{document}
\maketitle
\begin{figure*}
\centering
\begin{tikzpicture}[scale=0.7]
\begin{axis}[
ylabel={y axis},
xlabel = {Thresholds},
width = 1.8*\textwidth,
height = 18cm,
scaled y ticks = false,
y tick label style={font=\large},
y label style={font=\Large},
x tick label style={font=\large},
x label style={font=\Large},
y label style={at={(axis description cs:-0.06,.5)},anchor=south},
symbolic x coords={\avtwo, \avplus, \av, \avgdivt, \avgdivf, \avgdive},
xtick=data,
x tick label style={},
nodes near coords align={vertical},
legend cell align=right,
legend style={font=\Large,at={(0.173,1.12)},
anchor=north,legend columns=-1},
y coord trafo/.code={\pgfmathparse{-ln(99-#1)}},
y coord inv trafo/.code={\pgfmathparse{99-exp(-#1)}}
]
\addplot [only marks,mark=square*,mark size=4pt,color=red,mark options={solid},solid] coordinates{
(\avtwo,98.83) (\avplus,98.48) (\av,97.84) (\avgdivt,96.25) (\avgdivf,94.04) (\avgdive,90.92)
};
\addplot [only marks,mark=*, mark size=4pt,color=bblue,solid] coordinates{
(\avtwo,98.71) (\avplus,98.16) (\av,97.33) (\avgdivt,96.07) (\avgdivf,94.69) (\avgdive,92.53)
};
\addplot [only marks,mark=asterisk, mark size=5pt,color=ggreen,solid] coordinates{
(\avtwo,90.53) (\avplus,87.82) (\av,82.43) (\avgdivt,69.49) (\avgdivf,54.42) (\avgdive,40.93)
};
\addplot [only marks,mark=triangle*, mark size=5pt,color=ppurple,solid] coordinates{
(\avtwo,92.34) (\avplus,90.2) (\av,86.01) (\avgdivt,75.71) (\avgdivf,64.1) (\avgdive,53.96)
};
\addplot [only marks,mark=diamond*, mark size=5pt,color=mustard,solid] coordinates{
(\avtwo,90.33) (\avplus,87.58) (\av,82.31) (\avgdivt,69.84) (\avgdivf,58.12) (\avgdive,48.12)
};
\legend{DP,TR,SP,TR\_SP,SP\_TR}
\end{axis}
\end{tikzpicture}
\end{figure*}
\end{document}
请注意,你的情节太宽泛(我没有解决这个问题),你的序言加载了很多这里没有使用的东西,\tt
在上个千年末期已经被弃用了,切换到当前版本是一种很好的做法,目前是\pgfplotsset{compat=1.16}
。
答案2
- 我认为,这是不是一个
pgfplots
特定于的问题(甚至不是一个特定于 LaTeX 的问题)。 - 这是一个普遍适用于图表的问题。
- 基本上,你可以优化以下参数:(
height
越大越好),以及ymin
和之间的差异ymax
(越大越好)。 - 当然,您也可以改变标记的大小(
mark size
或mark options
)(越小越好)。