.csv 中的空字段问题

.csv 中的空字段问题

给出代码:

\documentclass{beamer}

\usepackage{pgfplots}
\usepackage{polski}
\usepackage{tikz}
\usetikzlibrary{intersections}
\usepackage{etoolbox}
\usepackage{pgf,tikz}
\usepackage{mathrsfs}
\usetikzlibrary{arrows}
\usetikzlibrary{calc}
\usepackage{ragged2e}
\usepackage[utf8]{inputenc}
\usepackage{xcolor,hyperref}
\usepackage{graphicx}
\usepackage{float}

\pgfplotsset{compat=1.8}
\usepackage{eurosym}      %<-- For EURO symbol 
\usepackage{filecontents}
\usepackage[export]{adjustbox}
\usetheme{boxes}
\usecolortheme{default}
\usefonttheme{serif}
\usepackage{tikz}
\setbeamertemplate{footline}[page number] % To replace the footer line in all slides with a simple slide count uncomment this line

\setbeamertemplate{navigation symbols}{} % To remove the navigation symbols from the bottom of all slides uncomment this line
\usetikzlibrary{shapes,arrows}
\beamersetaveragebackground{white}


%\AtBeginSection[] % Do nothing for \section*
%{
%   \begin{frame}<beamer>
%       \frametitle{Outline}
%       \tableofcontents[currentsection]
%   \end{frame}
%}

\begin{filecontents*}{data2.csv}
    in gna  gnb gnc gnd gne gnf gng'
1990.2328.93    10332.24    ""  4761.08 5685.17 ""  2640.73
1991    2299.86 9154.11 7525.01 4411.38 5386.18 ""  2413.58
1992    2074.59 9098.43   7297.28   4508.48 4601.50 6780.65 2173.23
1993    1912.62 9094.61  7263.52    4665.14 4207.40 6883.25 1863.03
1994    1690.82 9355.82  7487.83    4901.70 3683.10 7281.64 1442.90
1995    1519.88 9943.98   7609.95   5235.35 3529.55 7684.62 1276.92
1996    1567.67 10381.93    7626.33 5557.75 3407.44 8186.54 1159.47
1997    1753.80 10323.05    7903.44 5947.69 3460.86 8667.24 1134.98
1998    1910.19 10300.18    8255.34 6241.75 3282.86 9002.87 1123.41
1999    1981.83 10458.98    8547.34 6524.68 3503.79 8975.25 1131.78
2000    2103.06 10938.73    8931.84 6874.04 3870.41 9096.17 1210.69
2001    2219.52 11314.97    9296.94 6958.81 4084.78 9415.06 1335.43
2002    2346.39 11523.52    9741.22 7062.53 4298.28 9844.46 1418.90
2003    2529.08 11942.00    10144.68    7319.07 4632.85 10384.73    1564.92
2004    2838.06 12529.01    10669.19    7699.46 4985.33 10933.08    1767.64
2005    3126.37 13317.73    11155.96    7976.07 5323.47 11631.35    1828.72
2006    3460.13 14195.04    11598.64    8475.37 5776.40 12617.75    1975.53
2007    3775.00 14892.76    11666.09    9090.68 6280.15 13980.74    2144.35
2008    4174.02 15170.15    11784.63    9445.78 6612.63 14758.37    2205.58
2009    4191.61 14353.63    11028.74    9688.03 6093.63 13929.36    1887.52
2010    4524.16 14640.34    11135.84    10075.11    6365.21 14623.60    1974.62
2011    4783.53 14897.43    11363.71    10574.04    6631.46 15019.81    2084.78
2012    4870.98 14742.66    11229.63    10739.20    6845.77 15222.69    2094.12
2013    4922.24 14659.93    11473.40    10881.59    6922.80 15423.47    2098.89
2014    4998.28 14955.20    11932.61    11257.60    6843.92 15797.52    2081.06


\end{filecontents*}
\title{Eyyyynej}
\author{Anjjjjjk}
\date{16 marca 2016}

\usepackage{pgfplots, pgfplotstable}

\begin{document}

            \begin{frame}{Wwwp}
                        \begin{adjustbox}{max totalsize={\textwidth}{0.9\textheight},center}
                            \begin{tikzpicture}
                            \centering
                            \begin{axis}[
                            width=\textwidth,
                            height=10cm,
                            ymajorgrids,
                            title = {Źródło: Opracoweeeedstawie Woqqwqwqpment Indicators},
                            x tick label style={/pgf/number format/1000 sep=},
                            ytick scale label code/.code={},
                            legend pos=outer north east,
                            ylabel={PKB per capita (2005 US\$)}
                            ]
                            \addplot[mark=x, violet, very thick] table[x=in,y=gna] {data2.csv};\addlegendentry{Białoruś}
                            \addplot table[x=in,y=gnb] {data2.csv};\addlegendentry{Czechy}

                            \addplot table[x=in,y=gnc] {data2.csv};\addlegendentry{Węgry}
                            \addplot table[x=in,y=gnd] {data2.csv};\addlegendentry{Polska}
                            \addplot table[x=in,y=gne] {data2.csv};\addlegendentry{Rosja}
                            \addplot[green, very thick] table[x=in,y=gnf] {data2.csv};\addlegendentry{Słowacja}
                            \addplot[pink, very thick] table[x=in,y=gng] {data2.csv};\addlegendentry{Ukraina}
                            \end{axis}
                            \end{tikzpicture}

                        \end{adjustbox}
            \end{frame}

    \end{document}

在“”的位置,我输入了空字段,这意味着此单元格没有可用数据,如何制作带有空单元格的图表?因为现在此图表不想编译。

答案1

使用{}作为空单元格并更正表格中的拼写错误:第一行末尾的 gng 和第二行开头的 1990 2328.93。

在此处输入图片描述

代码:

\documentclass{beamer}% loads hyperref
\usepackage{polski}
\usepackage{pgfplotstable}% loads pgfplots, tikz, pgf, xcolor, graphicx
\pgfplotsset{compat=1.8}% current version would be 1.14
\usetikzlibrary{intersections}
\usetikzlibrary{arrows}
\usetikzlibrary{calc}
\usetikzlibrary{shapes}
\usepackage{etoolbox}
\usepackage{mathrsfs}
\usepackage{float}
\usepackage{ragged2e}
\usepackage[utf8]{inputenc}
\usepackage{eurosym} 
\usepackage{filecontents}
\usepackage[export]{adjustbox}

\usetheme{boxes}
\usecolortheme{default}
\usefonttheme{serif}
\setbeamertemplate{footline}[page number] % To replace the footer line in all slides with a simple slide count uncomment this line
\setbeamertemplate{navigation symbols}{} % To remove the navigation symbols from the bottom of all slides uncomment this line
\beamersetaveragebackground{white}


\begin{filecontents*}{data2.csv}
    in gna  gnb gnc gnd gne gnf gng
1990    2328.93 10332.24    {}  4761.08 5685.17 {}  2640.73
1991    2299.86 9154.11 7525.01 4411.38 5386.18 {}  2413.58
1992    2074.59 9098.43   7297.28   4508.48 4601.50 6780.65 2173.23
1993    1912.62 9094.61  7263.52    4665.14 4207.40 6883.25 1863.03
1994    1690.82 9355.82  7487.83    4901.70 3683.10 7281.64 1442.90
1995    1519.88 9943.98   7609.95   5235.35 3529.55 7684.62 1276.92
1996    1567.67 10381.93    7626.33 5557.75 3407.44 8186.54 1159.47
1997    1753.80 10323.05    7903.44 5947.69 3460.86 8667.24 1134.98
1998    1910.19 10300.18    8255.34 6241.75 3282.86 9002.87 1123.41
1999    1981.83 10458.98    8547.34 6524.68 3503.79 8975.25 1131.78
2000    2103.06 10938.73    8931.84 6874.04 3870.41 9096.17 1210.69
2001    2219.52 11314.97    9296.94 6958.81 4084.78 9415.06 1335.43
2002    2346.39 11523.52    9741.22 7062.53 4298.28 9844.46 1418.90
2003    2529.08 11942.00    10144.68    7319.07 4632.85 10384.73    1564.92
2004    2838.06 12529.01    10669.19    7699.46 4985.33 10933.08    1767.64
2005    3126.37 13317.73    11155.96    7976.07 5323.47 11631.35    1828.72
2006    3460.13 14195.04    11598.64    8475.37 5776.40 12617.75    1975.53
2007    3775.00 14892.76    11666.09    9090.68 6280.15 13980.74    2144.35
2008    4174.02 15170.15    11784.63    9445.78 6612.63 14758.37    2205.58
2009    4191.61 14353.63    11028.74    9688.03 6093.63 13929.36    1887.52
2010    4524.16 14640.34    11135.84    10075.11    6365.21 14623.60    1974.62
2011    4783.53 14897.43    11363.71    10574.04    6631.46 15019.81    2084.78
2012    4870.98 14742.66    11229.63    10739.20    6845.77 15222.69    2094.12
2013    4922.24 14659.93    11473.40    10881.59    6922.80 15423.47    2098.89
2014    4998.28 14955.20    11932.61    11257.60    6843.92 15797.52    2081.06
\end{filecontents*}
\title{Eyyyynej}
\author{Anjjjjjk}
\date{16 marca 2016}

\begin{document}
\begin{frame}{Wwwp}
  \begin{adjustbox}{max totalsize={\textwidth}{0.9\textheight},center}
    \begin{tikzpicture}
      \begin{axis}[
      width=\textwidth,
      height=10cm,
      ymajorgrids,
      title = {Źródło: Opracoweeeedstawie Woqqwqwqpment Indicators},
      x tick label style={/pgf/number format/1000 sep=},
      ytick scale label code/.code={},
      legend pos=outer north east,
      ylabel={PKB per capita (2005 US\$)}
      ]
      \addplot[mark=x, violet, very thick] table[x=in,y=gna] {data2.csv};\addlegendentry{Białoruś}
      \addplot table[x=in,y=gnb] {data2.csv};\addlegendentry{Czechy}

      \addplot table[x=in,y=gnc] {data2.csv};\addlegendentry{Węgry}
      \addplot table[x=in,y=gnd] {data2.csv};\addlegendentry{Polska}
      \addplot table[x=in,y=gne] {data2.csv};\addlegendentry{Rosja}
      \addplot[green, very thick] table[x=in,y=gnf] {data2.csv};\addlegendentry{Słowacja}
      \addplot[pink, very thick] table[x=in,y=gng] {data2.csv};\addlegendentry{Ukraina}
      \end{axis}
    \end{tikzpicture}
  \end{adjustbox}
\end{frame}
\end{document}

备注:不要多次加载包。

相关内容