Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Figure out a way to have the options of an AxisLike object to be close to its constructor name. #37

Closed
KristofferC opened this issue Jan 16, 2018 · 2 comments

Comments

@KristofferC
Copy link
Owner

KristofferC commented Jan 16, 2018

Here is an example:

pgf.@pgf begin
axis = pgf.Axis(
    pgf.Plot(
        pgf.Coordinates(
            [
                (2, -2.8559703),
                (3, -3.5301677),
                (4, -4.3050655),
                (5, -5.1413136),
                (6, -6.0322865),
                (7, -6.9675052),
                (8, -7.9377747),
            ]
        ),
        {
            color = "red",
            mark  = "x"
        }
    ),
    {
        xlabel = "Cost",
	ylabel = "Error",
    }
)
end

The "problem" here is that the options for e.g. the Axis are very far away from the start of the Axis command. In .tex, the options are close to the begin{axis}. Perhaps one should be able to use a keyword argument or dispatch on the type. The problem with dispatching on the type is of course something like Axis("foo", "bar")...

@tpapp
Copy link
Collaborator

tpapp commented Jan 16, 2018

We should think hard about unifying constructor syntax for Axis, Plot, Table, Coordinates, etc. These take a combination of keyword => value pairs, associative collections which are sometimes options, vectors and matrices, etc. This leads to many combinations, and sometimes validation happens only with print_tex.

We could require that all options are put in a wrapper type, eg Options (could still be OrderedDict internally), which can then be dispatched on. @pgf would produce this wrapper automatically.

@KristofferC
Copy link
Owner Author

This work on master now by dispatching on an ordered dict as first argument. Not ideal but rest can be dealt with in #44.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants