使用表格*图例格式化 pgfplots 条形图

使用表格*图例格式化 pgfplots 条形图

当我尝试更改条形图的大小以使其位于图例上方的中央时,我无法使高度和宽度同时符合我的规格。总有一个尺寸太小。

理想情况下,条形图的宽度应与图例的宽度相匹配,轴标签的字体大小应与图例的字体大小相匹配,并且条形图的高度应比现在高得多,以便于阅读。

我正在使用 \center\footnotesize来制作图表和图例,但它们的工作方式似乎略有不同。

任何指导都值得感激。

在此处输入图片描述

\documentclass[twoside,12pt]{article}
\usepackage{lscape}
\usepackage{pgfplots}

\begin{document}
\begin{landscape}
\center{Figure 1}
\pgfplotsset{
tick label style={font=\footnotesize},
label style={font=\footnotesize},
legend style={font=\footnotesize}
}
\begin{center}
    \resizebox{!}{0.2\linewidth}{
    \begin{tikzpicture}
       \begin{axis}[
            width=7cm,
            symbolic x coords={1, 2, 3,4,5,6,7,8,9,10,11,12,13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 
            25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,},
            xtick=data,
            xlabel=Fama-French 48 Industry Code,
            ylabel=No. Observations,
            ytick={20,40,60,80},
            x=.5cm,
            ymin=0,
            enlarge x limits=0.02,
          ]
            \addplot[ybar,fill=blue] coordinates {
            (1,1)
(2,17)
(3,2)
(4,5)
(5,2)
(6,3)
(7,4)
(8,7)
(9,17)
(10,10)
(11,9)
(12,14)
(13,24)
(14,34)
(15,5)
(16,4)
(17,17)
(18,9)
(19,14)
(20,1)
(21,32)
(22,10)
(23,21)
(24,6)
(25,2)
(26,4)
(27,4)
(28,4)
(29,0)
(30,36)
(31,67)
(32,18)
(33,6)
(34,48)
(35,14)
(36,33)
(37,14)
(38,25)
(39,3)
(40,21)
(41,23)
(42,48)
(43,17)
(44,50)
(45,30)
(46,0)
(47,9)
(48,7)
            };
        \end{axis}
    \end{tikzpicture}}\end{center}

\footnotesize
\begin{center}
\begin{tabular*}
{\columnwidth}
{@{\extracolsep{\fill}}l@{\extracolsep{\fill}}
r@{\extracolsep{0in}}@{.}
l@{\extracolsep{\fill}}
r@{\extracolsep{0in}}@{.}
l@{\extracolsep{\fill}}
r@{\extracolsep{0in}}@{.}
l@{\extracolsep{\fill}}
r@{\extracolsep{0in}}@{.}
l@{\extracolsep{\fill}}
r@{\extracolsep{0in}}@{.}
l@{\extracolsep{\fill}}
r@{\extracolsep{0in}}@{.}l}

\hline
\multicolumn{2}{c}{Code} & \multicolumn{2}{c}{Industry} & \multicolumn{2}{c}{Code} & \multicolumn{2}{c}{Industry} & \multicolumn{2}{c}{Code} & \multicolumn{2}{c}{Industry}\\
\hline
\multicolumn{2}{c}{1} & \multicolumn{2}{c}{Agriculture} & \multicolumn{2}{c}{17} & \multicolumn{2}{c}{Construction Materials} & \multicolumn{2}{c}{33} & \multicolumn{2}{c}{Personal Services}\\


\multicolumn{2}{c}{2} & \multicolumn{2}{c}{Food Products} & \multicolumn{2}{c}{18} & \multicolumn{2}{c}{Construction} & \multicolumn{2}{c}{34} & \multicolumn{2}{c}{Business Services}\\


\multicolumn{2}{c}{3} & \multicolumn{2}{c}{Candy \& Soda} & \multicolumn{2}{c}{19} & \multicolumn{2}{c}{Steel Works Etc} & \multicolumn{2}{c}{35} & \multicolumn{2}{c}{Computers}\\


\multicolumn{2}{c}{4} & \multicolumn{2}{c}{Beer \& Liquor} & \multicolumn{2}{c}{20} & \multicolumn{2}{c}{Fabricated Products} & \multicolumn{2}{c}{36} & \multicolumn{2}{c}{Electronic Equipment}\\


\multicolumn{2}{c}{5} & \multicolumn{2}{c}{Tobacco Products} & \multicolumn{2}{c}{21} & \multicolumn{2}{c}{Machinery} & \multicolumn{2}{c}{37} & \multicolumn{2}{c}{Measuring \& Control Equipment}\\


\multicolumn{2}{c}{6} & \multicolumn{2}{c}{Recreation} & \multicolumn{2}{c}{22} & \multicolumn{2}{c}{Electrical Equipment} & \multicolumn{2}{c}{38} & \multicolumn{2}{c}{Business Supplies}\\


\multicolumn{2}{c}{7} & \multicolumn{2}{c}{Entertainment} & \multicolumn{2}{c}{23} & \multicolumn{2}{c}{Automobiles \& Trucks} & \multicolumn{2}{c}{39} & \multicolumn{2}{c}{Shipping Containers}\\


\multicolumn{2}{c}{8} & \multicolumn{2}{c}{Printing \& Publishing} & \multicolumn{2}{c}{24} & \multicolumn{2}{c}{Aircraft}& \multicolumn{2}{c}{40} & \multicolumn{2}{c}{Transportation}\\


\multicolumn{2}{c}{9} & \multicolumn{2}{c}{Consumer Goods} & \multicolumn{2}{c}{25} & \multicolumn{2}{c}{Shipbuilding, Railroad Eq.} & \multicolumn{2}{c}{41} & \multicolumn{2}{c}{Wholesale}\\


\multicolumn{2}{c}{10} & \multicolumn{2}{c}{Apparel} & \multicolumn{2}{c}{26} & \multicolumn{2}{c}{Defense} & \multicolumn{2}{c}{42} & \multicolumn{2}{c}{Retail}\\


\multicolumn{2}{c}{11} & \multicolumn{2}{c}{Healthcare} & \multicolumn{2}{c}{27} & \multicolumn{2}{c}{Precious Metals} & \multicolumn{2}{c}{43} & \multicolumn{2}{c}{Restaurants, Hotels, Motels}\\


\multicolumn{2}{c}{12} & \multicolumn{2}{c}{Medical Equipment} & \multicolumn{2}{c}{28} & \multicolumn{2}{c}{Mining} & \multicolumn{2}{c}{44} & \multicolumn{2}{c}{Banking}\\


\multicolumn{2}{c}{13} & \multicolumn{2}{c}{Pharmaceutical Products} & \multicolumn{2}{c}{29} & \multicolumn{2}{c}{Coal} & \multicolumn{2}{c}{45} & \multicolumn{2}{c}{Insurance}\\


\multicolumn{2}{c}{14} & \multicolumn{2}{c}{Chemicals} & \multicolumn{2}{c}{30} & \multicolumn{2}{c}{Petroleum \& Natural Gas} & \multicolumn{2}{c}{46} & \multicolumn{2}{c}{Real Estate}\\


\multicolumn{2}{c}{15} & \multicolumn{2}{c}{Rubber \& Plastics} & \multicolumn{2}{c}{31} & \multicolumn{2}{c}{Utilities} & \multicolumn{2}{c}{47} & \multicolumn{2}{c}{Trading}\\


\multicolumn{2}{c}{16} & \multicolumn{2}{c}{Textiles} & \multicolumn{2}{c}{32} & \multicolumn{2}{c}{Communication} & \multicolumn{2}{c}{48} & \multicolumn{2}{c}{Other}\\

\hline
\end{tabular*}
\end{center}
Figure 1 provides descriptive statistics on adoptions by Fama-French 48 industry classification.
\end{landscape}
\end{document} 

相关内容