Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

How can I convert the automatic table generated by the macro, to an automatic histogram? Is the best way do it using pgfplots?

\documentclass{article}

\RequirePackage{ifthen}
\RequirePackage{siunitx}
\RequirePackage{booktabs}
\RequirePackage{xparse}

% **********************************************************
\ExplSyntaxOn
% **********************************************************

\tl_const:Nx \c_aw_the_alphabet_tl {abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ,.;?()!' \token_to_str:N :}

\tl_new:N \l_aw_tab_rows_tl
\seq_new:N \g_aw_theor_rats_seq
\seq_new:N \g_aw_the_alphabet_seq

\seq_gset_split:Nnn \g_aw_theor_rats_seq {,}
{0.0651738,0.0124248,0.0217339,0.0349835,0.1041442,0.0197881,0.0158610,0.0492888,0.0558094,0.0009033,0.0050529,0.0331490,0.0202124,0.0564513,0.0596302,0.0137645,0.0008606,0.0497563,0.0515760,0.0729357,0.0225134,0.0082903,0.0171272,0.0013692,0.0145984,0.0007836,0.1918182}


\NewDocumentCommand {\showtable}{}
    {
      \clearpage
      \thispagestyle{empty}
      \aw_make_table:
    }

\cs_generate_variant:Nn \seq_set_split:Nnn {NnV}
\cs_new:Npn \aw_make_table:
    {
      \seq_set_split:NnV \g_aw_the_alphabet_seq {} \c_aw_the_alphabet_tl
      %takes corresponding letter/theoretical ratio pairs from sequences and applies function
      \seq_mapthread_function:NNN \g_aw_the_alphabet_seq \g_aw_theor_rats_seq \aw_generate_row:nn
    \begin{table}
        \centering
        \footnotesize
      \begin{tabular}{cS}
        \toprule
        {Letter}&{Actual}\\
        \midrule
        \textvisiblespace&1\%\\
        \tl_use:N \l_aw_tab_rows_tl
        \bottomrule
      \end{tabular}\par
    \end{table}
    }

\cs_new:Npn \aw_generate_row:nn #1#2
    {
      \tl_put_right:Nn \l_aw_tab_rows_tl {#1&}
      \tl_put_right:Nn \l_aw_tab_rows_tl {\fp_eval:n{100*{#2}}\%}
      \tl_put_right:Nn \l_aw_tab_rows_tl {\\}
    }

% **********************************************************
\ExplSyntaxOff
% **********************************************************

\begin{document}

\showtable{}

\end{document}

I have try this way but I get some errors:

...

\usepackage{pgfplots}

\pgfplotsset{%
            /pgf/number format/use comma,%
            compat=newest}

... 

\begin{figure}
\centering
  \begin{tikzpicture}
    \begin{axis}
    \addplot coordinates{%
                        (\textvisiblespace,1)
                        \tl_use:N \l_aw_tab_rows_tl%
                        };
    \end{axis}
  \end{tikzpicture}
\caption{histogram.}
\end{figure}

...

\cs_new:Npn \aw_generate_row:n #1
    {
       \tl_put_right:Nn \l_aw_tab_rows_tl {(#1,}
      \tl_put_right:Nn \l_aw_tab_rows_tl {\fp_eval:n{100*{#2}})}
    }

...
share|improve this question

closed as unclear what you're asking by Joseph Wright Aug 2 at 21:50

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

    
There aren't answer for this question, because Is it impossible to do? –  FormlessCloud Oct 10 '12 at 17:16
4  
I think it's because in order to understand the question, people first have to compile a huge chunk of code without understanding what that code is supposed to do. It's not a minimal example, far from it, which really makes this too localised. –  Jake Oct 10 '12 at 17:46
    
@Jake But this is the minimum code that is required for the functioning of the macro. And I have thinked that the meaning of the macro is explained from the characters table. –  FormlessCloud Oct 10 '12 at 19:38
1  
But the actual functionality of the macro has nothing to do with the problem. You could have written a much simpler macro that just generates some random numbers (or something like that), which would make it much easier to determine where the problem lies, and it would make it easier for others who are facing similar problems to see whether this question is relevant. –  Jake Oct 10 '12 at 19:49
1  
@Jake You are right, but I haven't write myself this macro, and I don't know how create other similar macro with that language of programming. So I'll try to learn how can I write something like your advice, and update this question. –  FormlessCloud Oct 10 '12 at 20:05