我正在尝试创建一个包含 32 个项目的大条形图。我怎样才能将其分成两页?我尝试使用subfigure
(如下所示)在 16 日将其分开;但是,它没有分成两页。
其次,如何使用bchart
包添加图例?
\documentclass[12pt]{article}
\usepackage{bchart}
\usepackage{subcaption}
\begin{document}
\begin{figure}[htbp]
\centering
\begin{subfigure}[b]{\linewidth}
\centering
\begin{bchart}[max = 55, step = 10, scale=0.8]
\bcbar{49.8}
\bcbar[label=Greece, color=green!70!blue]{28.9}
\bcbar[color=red!50]{24.9}
\smallskip
\bcbar{48.3}
\bcbar[label=Spain, color=green!70!blue]{23.6}
\bcbar[color=red!50]{22.1}
\smallskip
\bcbar{43}
\bcbar[label=Croatia, color=green!70!blue]{17}
\bcbar[color=red!50]{16.3}
\smallskip
\bcbar{40.3}
\bcbar[label=Italy, color=green!70!blue]{12.7}
\bcbar[color=red!50]{11.9}
\smallskip
\bcbar{32.8}
\bcbar[label=Cyprus, color=green!70!blue]{14.8}
\bcbar[color=red!50]{15}
\smallskip
\bcbar{32}
\bcbar[label=Portugal, color=green!70!blue]{12.9}
\bcbar[color=red!50]{12.6}
\smallskip
\bcbar{26.5}
\bcbar[label=Slovakia, color=green!70!blue]{12.9}
\bcbar[color=red!50]{11.5}
\smallskip
\bcbar{24.7}
\bcbar[label=France, color=green!70!blue]{9.9}
\bcbar[color=red!50]{10.4}
\smallskip
\bcbar{22.4}
\bcbar[label=EURO Area, color=green!70!blue]{11}
\bcbar[color=red!50]{10.9}
\smallskip
\bcbar{16.3}
\bcbar[label=Latvia, color=green!70!blue]{8.6}
\bcbar[color=red!50]{9.9}
\smallskip
\bcbar{22.4}
\bcbar[label=Finland, color=green!70!blue]{8.8}
\bcbar[color=red!50]{9.4}
\smallskip
\bcbar{20.9}
\bcbar[label=Ireland, color=green!70!blue]{7.7}
\bcbar[color=red!50]{9.4}
\smallskip
\bcbar{20.3}
\bcbar[label=EU (28 countries), color=green!70!blue]{9.5}
\bcbar[color=red!50]{9.4}
\smallskip
\bcbar{21.6}
\bcbar[label=Bulgaria, color=green!70!blue]{8.4}
\bcbar[color=red!50]{9.2}
\smallskip
\bcbar{16.3}
\bcbar[label=Lithuania, color=green!70!blue]{8.2}
\bcbar[color=red!50]{9.1}
\smallskip
\bcbar{16.3}
\bcbar[label=Slovenia, color=green!70!blue]{10.1}
\bcbar[color=red!50]{8.5}
\smallskip
\bcbar{22.1}
\bcbar[label=Belgium, color=green!70!blue]{7.8}
\bcbar[color=red!50]{8.5}
\smallskip
\end{bchart}
\caption{}
\end{subfigure}
\begin{subfigure}[b]{\linewidth}
\centering
\begin{bchart}[max = 55, step = 10, scale=0.8]
\bcbar{20.8}
\bcbar[label=Poland, color=green!70!blue]{7.7}
\bcbar[color=red!50]{7.5}
\smallskip
\bcbar{20.4}
\bcbar[label=Sweden, color=green!70!blue]{7.3}
\bcbar[color=red!50]{7.4}
\smallskip
\bcbar{11.3}
\bcbar[label=Netherlands, color=green!70!blue]{7.3}
\bcbar[color=red!50]{6.9}
\smallskip
\bcbar{21.7}
\bcbar[label=Romania, color=green!70!blue]{5.8}
\bcbar[color=red!50]{6.8}
\smallskip
\bcbar{17.3}
\bcbar[label=Hungary, color=green!70!blue]{7.0}
\bcbar[color=red!50]{6.8}
\smallskip
\bcbar{16.6}
\bcbar[label=Luxembourg, color=green!70!blue]{7.1}
\bcbar[color=red!50]{6.4}
\smallskip
\bcbar{13.1}
\bcbar[label=Estonia, color=green!70!blue]{6.1}
\bcbar[color=red!50]{6.2}
\smallskip
\bcbar{10.8}
\bcbar[label=Denmark, color=green!70!blue]{6.4}
\bcbar[color=red!50]{6.2}
\smallskip
\bcbar{10.6}
\bcbar[label=Austria, color=green!70!blue]{5.3}
\bcbar[color=red!50]{5.7}
\smallskip
\bcbar{11.8}
\bcbar[label=Malta, color=green!70!blue]{5.2}
\bcbar[color=red!50]{5.4}
\smallskip
\bcbar{14.6}
\bcbar[label=United Kingdom, color=green!70!blue]{5.1}
\bcbar[color=red!50]{5.3}
\smallskip
\bcbar{12.6}
\bcbar[label=Czech Republic, color=green!70!blue]{6.1}
\bcbar[color=red!50]{5.1}
\smallskip
\bcbar{7.2}
\bcbar[label=Germany, color=green!70!blue]{4.2}
\bcbar[color=red!50]{4.6}
\smallskip
\bcbar{9.9}
\bcbar[label=Norway, color=green!70!blue]{4.0}
\bcbar[color=red!50]{4.4}
\smallskip
\bcbar{8.8}
\bcbar[label=Iceland, color=green!70!blue]{4.1}
\bcbar[color=red!50]{4.0}
\smallskip
\end{bchart}
\caption{}
\end{subfigure}
\caption{Unemployment rate: 2015}
\end{figure}
\end{document}
答案1
此答案中有两个不同的建议,因此请滚动到末尾。图例仅在第二个建议中实现,但您可以对第一个建议使用相同的技术。
分为两页
环境figure
不能跨页面拆分,因此仅使用两个subfigure
环境是不够的。使用两个figure
环境,删除subfigure
环境,然后\ContinuedFloat
在第二个中使用figure
。不过,您仍然需要将其缩小到比现在更多的比例,以使图表的一半适合一页。
\documentclass[12pt]{article}
\usepackage{bchart}
\usepackage{subcaption}
\begin{document}
\begin{figure}[htbp]
\centering
\renewcommand\bcfontstyle{\sffamily\scriptsize}
\begin{bchart}[max = 55, step = 10, scale=0.6]
\bcbar{49.8}
\bcbar[label=Greece, color=green!70!blue]{28.9}
\bcbar[color=red!50]{24.9}
\smallskip
\bcbar{48.3}
\bcbar[label=Spain, color=green!70!blue]{23.6}
\bcbar[color=red!50]{22.1}
\smallskip
\bcbar{43}
\bcbar[label=Croatia, color=green!70!blue]{17}
\bcbar[color=red!50]{16.3}
\smallskip
\bcbar{40.3}
\bcbar[label=Italy, color=green!70!blue]{12.7}
\bcbar[color=red!50]{11.9}
\smallskip
\bcbar{32.8}
\bcbar[label=Cyprus, color=green!70!blue]{14.8}
\bcbar[color=red!50]{15}
\smallskip
\bcbar{32}
\bcbar[label=Portugal, color=green!70!blue]{12.9}
\bcbar[color=red!50]{12.6}
\smallskip
\bcbar{26.5}
\bcbar[label=Slovakia, color=green!70!blue]{12.9}
\bcbar[color=red!50]{11.5}
\smallskip
\bcbar{24.7}
\bcbar[label=France, color=green!70!blue]{9.9}
\bcbar[color=red!50]{10.4}
\smallskip
\bcbar{22.4}
\bcbar[label=EURO Area, color=green!70!blue]{11}
\bcbar[color=red!50]{10.9}
\smallskip
\bcbar{16.3}
\bcbar[label=Latvia, color=green!70!blue]{8.6}
\bcbar[color=red!50]{9.9}
\smallskip
\bcbar{22.4}
\bcbar[label=Finland, color=green!70!blue]{8.8}
\bcbar[color=red!50]{9.4}
\smallskip
\bcbar{20.9}
\bcbar[label=Ireland, color=green!70!blue]{7.7}
\bcbar[color=red!50]{9.4}
\smallskip
\bcbar{20.3}
\bcbar[label=EU (28 countries), color=green!70!blue]{9.5}
\bcbar[color=red!50]{9.4}
\smallskip
\bcbar{21.6}
\bcbar[label=Bulgaria, color=green!70!blue]{8.4}
\bcbar[color=red!50]{9.2}
\smallskip
\bcbar{16.3}
\bcbar[label=Lithuania, color=green!70!blue]{8.2}
\bcbar[color=red!50]{9.1}
\smallskip
\bcbar{16.3}
\bcbar[label=Slovenia, color=green!70!blue]{10.1}
\bcbar[color=red!50]{8.5}
\end{bchart}
\caption{Unemployment rate: 2015}
\end{figure}
\begin{figure}
\centering
\ContinuedFloat
\renewcommand\bcfontstyle{\sffamily\scriptsize}
\begin{bchart}[max = 55, step = 10, scale=0.6]
\bcbar{22.1}
\bcbar[label=Belgium, color=green!70!blue]{7.8}
\bcbar[color=red!50]{8.5}
\smallskip
\bcbar{20.8}
\bcbar[label=Poland, color=green!70!blue]{7.7}
\bcbar[color=red!50]{7.5}
\smallskip
\bcbar{20.4}
\bcbar[label=Sweden, color=green!70!blue]{7.3}
\bcbar[color=red!50]{7.4}
\smallskip
\bcbar{11.3}
\bcbar[label=Netherlands, color=green!70!blue]{7.3}
\bcbar[color=red!50]{6.9}
\smallskip
\bcbar{21.7}
\bcbar[label=Romania, color=green!70!blue]{5.8}
\bcbar[color=red!50]{6.8}
\smallskip
\bcbar{17.3}
\bcbar[label=Hungary, color=green!70!blue]{7.0}
\bcbar[color=red!50]{6.8}
\smallskip
\bcbar{16.6}
\bcbar[label=Luxembourg, color=green!70!blue]{7.1}
\bcbar[color=red!50]{6.4}
\smallskip
\bcbar{13.1}
\bcbar[label=Estonia, color=green!70!blue]{6.1}
\bcbar[color=red!50]{6.2}
\smallskip
\bcbar{10.8}
\bcbar[label=Denmark, color=green!70!blue]{6.4}
\bcbar[color=red!50]{6.2}
\smallskip
\bcbar{10.6}
\bcbar[label=Austria, color=green!70!blue]{5.3}
\bcbar[color=red!50]{5.7}
\smallskip
\bcbar{11.8}
\bcbar[label=Malta, color=green!70!blue]{5.2}
\bcbar[color=red!50]{5.4}
\smallskip
\bcbar{14.6}
\bcbar[label=United Kingdom, color=green!70!blue]{5.1}
\bcbar[color=red!50]{5.3}
\smallskip
\bcbar{12.6}
\bcbar[label=Czech Republic, color=green!70!blue]{6.1}
\bcbar[color=red!50]{5.1}
\smallskip
\bcbar{7.2}
\bcbar[label=Germany, color=green!70!blue]{4.2}
\bcbar[color=red!50]{4.6}
\smallskip
\bcbar{9.9}
\bcbar[label=Norway, color=green!70!blue]{4.0}
\bcbar[color=red!50]{4.4}
\smallskip
\bcbar{8.8}
\bcbar[label=Iceland, color=green!70!blue]{4.1}
\bcbar[color=red!50]{4.0}
\smallskip
\end{bchart}
\caption{Unemployment rate: 2015}
\end{figure}
\end{document}
两列
我不知道您的要求,但如果您将其缩小一点,并将其拆分到bchart
环境中,您就可以通过将两个图表彼此相邻来将其放在一页中。
粗略浏览一下手册,似乎bchart
没有任何制作图例的方法,但它是围绕 TikZ 构建的,因此您可以matrix
手动添加,请参阅代码末尾附近。
\documentclass[12pt]{article}
\usepackage{bchart}
\begin{document}
\begin{figure}
\renewcommand\bcfontstyle{\sffamily\scriptsize}
\centering
\begin{bchart}[max = 55, step = 10, scale=0.5]
\bcbar{49.8}
\bcbar[label=Greece, color=green!70!blue]{28.9}
\bcbar[color=red!50]{24.9}
\smallskip
\bcbar{48.3}
\bcbar[label=Spain, color=green!70!blue]{23.6}
\bcbar[color=red!50]{22.1}
\smallskip
\bcbar{43}
\bcbar[label=Croatia, color=green!70!blue]{17}
\bcbar[color=red!50]{16.3}
\smallskip
\bcbar{40.3}
\bcbar[label=Italy, color=green!70!blue]{12.7}
\bcbar[color=red!50]{11.9}
\smallskip
\bcbar{32.8}
\bcbar[label=Cyprus, color=green!70!blue]{14.8}
\bcbar[color=red!50]{15}
\smallskip
\bcbar{32}
\bcbar[label=Portugal, color=green!70!blue]{12.9}
\bcbar[color=red!50]{12.6}
\smallskip
\bcbar{26.5}
\bcbar[label=Slovakia, color=green!70!blue]{12.9}
\bcbar[color=red!50]{11.5}
\smallskip
\bcbar{24.7}
\bcbar[label=France, color=green!70!blue]{9.9}
\bcbar[color=red!50]{10.4}
\smallskip
\bcbar{22.4}
\bcbar[label=EURO Area, color=green!70!blue]{11}
\bcbar[color=red!50]{10.9}
\smallskip
\bcbar{16.3}
\bcbar[label=Latvia, color=green!70!blue]{8.6}
\bcbar[color=red!50]{9.9}
\smallskip
\bcbar{22.4}
\bcbar[label=Finland, color=green!70!blue]{8.8}
\bcbar[color=red!50]{9.4}
\smallskip
\bcbar{20.9}
\bcbar[label=Ireland, color=green!70!blue]{7.7}
\bcbar[color=red!50]{9.4}
\smallskip
\bcbar{20.3}
\bcbar[label=EU (28 countries), color=green!70!blue]{9.5}
\bcbar[color=red!50]{9.4}
\smallskip
\bcbar{21.6}
\bcbar[label=Bulgaria, color=green!70!blue]{8.4}
\bcbar[color=red!50]{9.2}
\smallskip
\bcbar{16.3}
\bcbar[label=Lithuania, color=green!70!blue]{8.2}
\bcbar[color=red!50]{9.1}
\smallskip
\bcbar{16.3}
\bcbar[label=Slovenia, color=green!70!blue]{10.1}
\bcbar[color=red!50]{8.5}
\end{bchart}
\begin{bchart}[max = 55, step = 10, scale=0.5]
\bcbar{22.1}
\bcbar[label=Belgium, color=green!70!blue]{7.8}
\bcbar[color=red!50]{8.5}
\smallskip
\bcbar{20.8}
\bcbar[label=Poland, color=green!70!blue]{7.7}
\bcbar[color=red!50]{7.5}
\smallskip
\bcbar{20.4}
\bcbar[label=Sweden, color=green!70!blue]{7.3}
\bcbar[color=red!50]{7.4}
\smallskip
\bcbar{11.3}
\bcbar[label=Netherlands, color=green!70!blue]{7.3}
\bcbar[color=red!50]{6.9}
\smallskip
\bcbar{21.7}
\bcbar[label=Romania, color=green!70!blue]{5.8}
\bcbar[color=red!50]{6.8}
\smallskip
\bcbar{17.3}
\bcbar[label=Hungary, color=green!70!blue]{7.0}
\bcbar[color=red!50]{6.8}
\smallskip
\bcbar{16.6}
\bcbar[label=Luxembourg, color=green!70!blue]{7.1}
\bcbar[color=red!50]{6.4}
\smallskip
\bcbar{13.1}
\bcbar[label=Estonia, color=green!70!blue]{6.1}
\bcbar[color=red!50]{6.2}
\smallskip
\bcbar{10.8}
\bcbar[label=Denmark, color=green!70!blue]{6.4}
\bcbar[color=red!50]{6.2}
\smallskip
\bcbar{10.6}
\bcbar[label=Austria, color=green!70!blue]{5.3}
\bcbar[color=red!50]{5.7}
\smallskip
\bcbar{11.8}
\bcbar[label=Malta, color=green!70!blue]{5.2}
\bcbar[color=red!50]{5.4}
\smallskip
\bcbar{14.6}
\bcbar[label=United Kingdom, color=green!70!blue]{5.1}
\bcbar[color=red!50]{5.3}
\smallskip
\bcbar{12.6}
\bcbar[label=Czech Republic, color=green!70!blue]{6.1}
\bcbar[color=red!50]{5.1}
\smallskip
\bcbar{7.2}
\bcbar[label=Germany, color=green!70!blue]{4.2}
\bcbar[color=red!50]{4.6}
\smallskip
\bcbar{9.9}
\bcbar[label=Norway, color=green!70!blue]{4.0}
\bcbar[color=red!50]{4.4}
\smallskip
\bcbar{8.8}
\bcbar[label=Iceland, color=green!70!blue]{4.1}
\bcbar[color=red!50]{4.0}
\matrix [
above left,
overlay,
every node/.style={
anchor=west,
font=\bcfontstyle}
] at ([xshift=5cm]current bounding box.south east) {
\filldraw [draw=black,fill=blue!20] (0,-0.1) rectangle +(0.7,0.25); & \node{Something}; \\
\filldraw [draw=black,fill=green!70!blue] (0,-0.1) rectangle +(0.7,0.25); & \node{Something else}; \\
\filldraw [draw=black,fill=red!50] (0,-0.1) rectangle +(0.7,0.25); & \node{Something weird}; \\
};
\end{bchart}
\caption{Unemployment rate: 2015}
\end{figure}
\end{document}