KristofferC / PGFPlotsX.jl

Plots in Julia using the PGFPlots LaTeX package
Other
301 stars 40 forks source link

prettify printing options #225

Open BeastyBlacksmith opened 4 years ago

BeastyBlacksmith commented 4 years ago

Before:

julia> p = @pgf Axis(
           {
               view = (0, 90),
               colorbar,
               "colormap/jet", shader = "flat",
           },
           Plot3(
               {
                   surf,
                   "mesh/cols" = 2,
                   point_meta = "explicit",
               },
               Table({x_index = 0, y_index = 1, meta_index = 2}, [1, 2, 3, 4], [1, 2, 3, 4], [1, 3, 2, 3])
           )
       );

julia> print_tex(p)
\begin{axis}[view={0}{90}, colorbar, colormap/jet, shader={flat}]
    \addplot3[surf, mesh/cols={2}, point meta={explicit}]
        table[row sep={\\}, x index={0}, y index={1}, meta index={2}]
        {
            \\
            1  1  1  \\
            2  2  3  \\
            3  3  2  \\
            4  4  3  \\
        }
        ;
\end{axis}

After:

julia> print_tex(p)
\begin{axis}[
    view={0}{90},
    colorbar,
    colormap/jet,
    shader={flat}
    ]
    \addplot3[
        surf,
        mesh/cols={2},
        point meta={explicit}
        ]
        table[
            row sep={\\},
            x index={0},
            y index={1},
            meta index={2}
            ]
        {
            \\
            1  1  1  \\
            2  2  3  \\
            3  3  2  \\
            4  4  3  \\
        }
        ;
\end{axis}
KristofferC commented 4 years ago

Nice, I thought about this very thing a few days ago after making some hand adjustments to a tex file produced by PGFPlotsX

BeastyBlacksmith commented 4 years ago

Yeah, the output of Plots plots is also hard to read otherwise. How can I run the doctests locally?

tpapp commented 4 years ago

I think that building the docs locally should do it.

BeastyBlacksmith commented 4 years ago

All lights green

tpapp commented 4 years ago

I am possibly an outlier here, but in most cases I prefer the compact output. I am fine with the pretty form being the default, but I am wondering if the old one could be preserved, eg via compact in IOContext.

Technically this would only require a branch in the code that was just changed, and preserving the old tests too in tests/, for the relevant input. (Again, I am fine with doctests etc including verbose output, and it being the default).

fredrikekre commented 4 years ago

Maybe just add some maximum column width instead of putting each option on its own line?

BeastyBlacksmith commented 4 years ago

I am not going to change anything in the near future, but feel free to change or add anything as you see fit.

BeastyBlacksmith commented 3 years ago

I added the option to get the compact output via IOContext. I can't see, why the docs fail to build though.