如何才能实现与截图一样的字体样式和绘图样式?
\documentclass[border=10pt]{standalone}
\usepackage{verbatim}
\usepackage{pgfplots}
\pgfplotsset{width=7cm,compat=1.8}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
ybar,
enlargelimits=0.15,
legend style={at={(0.5,-0.15)},
anchor=north,legend columns=-1},
ylabel={\#participants},
symbolic x coords={tool8,tool9,tool10},
xtick=data,
nodes near coords,
nodes near coords align={vertical},
]
\addplot coordinates {(tool8,7) (tool9,9) (tool10,4)};
\addplot coordinates {(tool8,4) (tool9,4) (tool10,4)};
\addplot coordinates {(tool8,1) (tool9,1) (tool10,1)};
\legend{used,understood,not understood}
\end{axis}
\end{tikzpicture}
\end{document}
答案1
嗯,字体看起来有点像\bfseries\sffamily
,你可以定义自己的bar cycle list
颜色。
\documentclass[border=10pt]{standalone}
\usepackage{pgfplots}
\definecolor{curlyblue}{RGB}{39,26,115}
\definecolor{curlygreen}{RGB}{48,172,140}
\pgfplotsset{width=7cm,compat=1.8}
\pgfplotsset{
/pgfplots/bar cycle list/.style={/pgfplots/cycle list={
{black,fill=curlyblue,mark=none},
{black,fill=curlygreen,mark=none},
{black,fill=yellow,mark=none},
}, }}
\begin{document}
\begin{tikzpicture}[font=\sffamily\bfseries]
\begin{axis}[
ybar,
enlargelimits=0.25,
legend style={at={(0.5,-0.15)},
anchor=north,legend columns=-1},
ylabel={\#participants},
symbolic x coords={tool8,tool9,tool10},
xtick=data,
nodes near coords,
nodes near coords align={vertical},
]
\addplot coordinates {(tool8,7) (tool9,9) (tool10,4)};
\addplot coordinates {(tool8,4) (tool9,4) (tool10,4)};
\addplot coordinates {(tool8,1) (tool9,1) (tool10,1)};
\legend{used,understood,not understood}
\end{axis}
\end{tikzpicture}
\end{document}
如果您想要在图表内显示图例,请将其设置legend columns
为 1,并使图表稍微大一些。
\documentclass[border=10pt]{standalone}
\usepackage{pgfplots}
\definecolor{curlyblue}{RGB}{39,26,115}
\definecolor{curlygreen}{RGB}{48,172,140}
\pgfplotsset{width=9cm,compat=1.8}
\pgfplotsset{
/pgfplots/bar cycle list/.style={/pgfplots/cycle list={
{black,fill=curlyblue,mark=none},
{black,fill=curlygreen,mark=none},
{black,fill=yellow,mark=none},
}, }}
\begin{document}
\begin{tikzpicture}[font=\sffamily\bfseries]
\begin{axis}[
ybar,
enlargelimits=0.25,
legend style={at={(0.75,0.95)},
anchor=north,legend columns=1},
ylabel={\#participants},
symbolic x coords={tool8,tool9,tool10},
xtick=data,
nodes near coords,
nodes near coords align={vertical},
]
\addplot coordinates {(tool8,7) (tool9,9) (tool10,4)};
\addplot coordinates {(tool8,4) (tool9,4) (tool10,4)};
\addplot coordinates {(tool8,1) (tool9,1) (tool10,1)};
\legend{used,understood,not understood}
\end{axis}
\end{tikzpicture}
\end{document}