Skip to content

Figure.legend: Support passing a StringIO object as the legend specification - #3438

Merged
seisman merged 43 commits into
mainfrom
legend/stringio
Sep 19, 2024
Merged

Figure.legend: Support passing a StringIO object as the legend specification#3438
seisman merged 43 commits into
mainfrom
legend/stringio

Conversation

@seisman

@seismanseisman commented Sep 12, 2024

Copy link
Copy Markdown
Member

Description of proposed changes

This PR adds StringIO support to Figure.legend, so that we can pass a StringIO object containing the legend specification to Figure.legend.

Need to wait for #3326.

Closes#571 and #576.

Example

importioimportpygmtspec=io.StringIO(
"""G -0.1iH 24p,Times-Roman My Map LegendD 0.2i 1pN 2V 0 1pS 0.1i c 0.15i p300/12 0.25p 0.3i This circle is hachuredS 0.1i e 0.15i yellow 0.25p 0.3i This ellipse is yellowS 0.1i w 0.15i green 0.25p 0.3i This wedge is greenS 0.1i f 0.25i blue 0.25p 0.3i This is a faultS 0.1i - 0.15i - 0.25p,- 0.3i A contourS 0.1i v 0.25i magenta 0.5p 0.3i This is a vectorS 0.1i i 0.15i cyan 0.25p 0.3i This triangle is boringD 0.2i 1pV 0 1pN 1M 5 5 600+u+fG 0.05iI @SOEST_block4.png 3i CTG 0.05iG 0.05iL 9p,Times-Roman R Smith et al., @%5%J. Geophys. Res., 99@%%, 2000G 0.1iT Let us just try some simple text that can go on a few lines.T There is no easy way to predetermine how many lines may be requiredT so we may have to adjust the height to get the right size box.""")
fig=pygmt.Figure()
fig.legend(spec, region=[0, 10, 0, 10], projection="M6i", position="x0.5i/0.5i+w5i+jBL+l1.2")
fig.show()

legend

@seismanseisman changed the title POC + WIP: Figure.legend: Support passing a StringIO object as the legend specificationFigure.legend: Support passing a StringIO object as the legend specificationSep 13, 2024
@seismanseisman added the enhancement Improving an existing feature label Sep 13, 2024
@seismanseisman added this to the 0.14.0 milestone Sep 13, 2024
Comment threadpygmt/tests/test_legend.py Outdated
Base automatically changed from api/virtualfile-from-stringio to mainSeptember 18, 2024 23:42
@seismanseisman added the needs review This PR has higher priority and needs review. label Sep 18, 2024
@seisman
seisman marked this pull request as ready for review September 18, 2024 23:43

@weiji14weiji14 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 Nice to close another >4 year old issue at #571!

@seismanseisman removed the needs review This PR has higher priority and needs review. label Sep 19, 2024
@seisman
seisman merged commit 5196ae6 into mainSep 19, 2024
@seisman
seisman deleted the legend/stringio branch September 19, 2024 04:57
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancementImproving an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow Figure.legend to read from StringIO

3 participants

@seisman@michaelgrund@weiji14