GenericMappingTools / GenericMappingTools/pygmt

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

Open
#3,252 4 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
874
Forks
255
Avg merge
1d 21h
Merged PRs (30d)
40

Description

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

Here is the minimal example:
```python
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](https://github.com/GenericMappingTools/pygmt/assets/3974108/f6582418-3b72-4192-8e70-42334e9bd7aa) | ![map](https://github.com/GenericMappingTools/pygmt/assets/3974108/9891cf01-4368-4e7e-beb3-45532d3e467c) |

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
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.