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

Confusing pen and fill behaviour for vector heads #753

Closed
adigitoleo opened this issue Nov 11, 2021 · 6 comments
Closed

Confusing pen and fill behaviour for vector heads #753

adigitoleo opened this issue Nov 11, 2021 · 6 comments

Comments

@adigitoleo
Copy link

adigitoleo commented Nov 11, 2021

Vector head fill and pen behaviour is inconsistent depending on nesting in the arrow NamedTuple.
Ideally, I would suggest to make it work only inside arrow, and disallow pen and fill keywords outside that context.
This makes it logically consistent: all arrow head properties are set inside arrow.
However, other functions accept pen and fill keywords also, so I'm not sure of the best solution.

using GMT

function example_data()
    Gz = gmt("grdmath -R-2/2/-2/2 -I0.1 X Y R2 NEG EXP X MUL =")
    Gdzdx = gmt("grdmath ? DDX", Gz)
    Gdzdy = gmt("grdmath ? DDY", Gz)
    return Gdzdx, Gdzdy
end

function test_arrow_fill()
    subplot(grid = "2x2", panels_size = 10, name = "test_arrow_fill.png")
    dx, dy = example_data()
    subplot(:set, panel = 1)
    grdvector(
        dx,
        dy,
        inc = 0.3,
        arrow = (; length = 0.4, shape = 0, stop = true, norm = 0.4, pen = :cyan, fill = :red),
        linewidth = 1,
    )
    subplot(:set, panel = 2)
    grdvector(
        dx,
        dy,
        inc = 0.3,
        arrow = (; length = 0.4, shape = 0, stop = true, norm = 0.4, fill = :red),
        pen = :cyan,
        linewidth = 1,
    )
    subplot(:set, panel = 3)
    grdvector(  # Produces the expected result.
        dx,
        dy,
        inc = 0.3,
        arrow = (; length = 0.4, shape = 0, stop = true, norm = 0.4, pen = :cyan),
        fill = :red,
        linewidth = 1,
    )
    subplot(:set, panel = 4)
    grdvector(
        dx,
        dy,
        inc = 0.3,
        arrow = (; length = 0.4, shape = 0, stop = true, norm = 0.4),
        fill = :red,
        pen = :cyan,
        linewidth = 1,
    )
    subplot(:end)
end

test_arrow_fill()

test_arrow_fill

@joa-quim
Copy link
Member

I see. Yes, confusing but we are obliged to use at least one of fill or pen outside arrow() otherwise GMT barfs with

grdvector [ERROR]: Must specify at least one of -G, -W, -C

Need to work out some trickery here.

@joa-quim
Copy link
Member

Can you please try #754 ?
It turns out that grdvector -W seems to be mandatory (looks like a bug to me), and since -Q (arrow()) is optional I didn't drop the fill and pen options from the base grdvector options, but I made them optional. Now you can set the fill and pen only from inside arrow(), or alternatively from base grdvector.

@adigitoleo
Copy link
Author

According to discussion in the linked PR, I've opened two related issues on the GMT tracker:

@joa-quim
Copy link
Member

joa-quim commented Nov 13, 2021

I opened a related (double) issue too GenericMappingTools/gmt#5988, including the transparency, which is already fixed.

@adigitoleo
Copy link
Author

Ah, oops I missed that one when I was looking through the tracker... Nice that the transparency is fixed.

@adigitoleo
Copy link
Author

OK I think this can be closed, the fixes have been released in GMT 6.3 upstream.

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