Skip to content

pygmt.config: pen settings are not reverted correctly when set in a context manager #3252

@seisman

Description

@seisman

Haven't found time to see why it doesn't work.

Here is the minimal example:

import pygmt

fig = pygmt.Figure()

fig.basemap(region=[0, 10, 0, 10], projection="X10c", frame=True)

fig.shift_origin(xshift="w+1")
with pygmt.config(MAP_FRAME_PEN="4p,blue"):
    fig.basemap(region=[0, 10, 0, 10], projection="X10c", frame=True)

fig.shift_origin(xshift="w+1")
fig.basemap(region=[0, 10, 0, 10], projection="X10c", frame=True)
fig.show()

The 3rd basemap is expected to have the default frame pen setting. Now the pen color is correct, but the pen thickness is incorrect:

Actual Expected
map map

The expected image is produced by:

gmt begin map
    gmt basemap -R0/10/0/10 -JX10c -Baf
    gmt basemap -R0/10/0/10 -JX10c -Baf -Xw+1c --MAP_FRAME_PEN=3p,blue
    gmt basemap -R0/10/0/10 -JX10c -Baf -Xw+1c
gmt end show

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions