Skip to content

Figure.text: Allow passing in a list/array of angle/font/justify values to text #483

Closed

Description

@weiji14

Description of the desired feature

Following up from #481 (review), it would be desirable if users can:

  1. Pass in a list/array of angle/font/justify values to text (currently only a single angle/font/justify value is allowed, and applied to all texts)
  2. Handle more flexible input formats, e.g., -F+a+j+f and -F+a+f+j (see also Figure.text: Parsing of additional arguments when plotting text from file #479 (comment)).

On the non-user facing side, it would be nice too if we can pass the x,y,text input via a virtualfile as mentioned in #321 (comment), instead of a temporary tab-delimited file. This will be a more efficient method of passing data around rather than relying on the pandas.to_csv method. Will need to modify virtualfile_from_vectors to accept str type arrays, see #481 (comment).

Are you willing to help implement and maintain this feature? Happy to review a PR for it 😄

Activity

  1. added
    help wanted
    feature request
    on Jun 21, 2020
  2. seisman commented on Jun 22, 2020

    @seisman
    Member

    Here are some technical notes, which may be useful (or may be wrong) if someone wants to implement this feature.

    1. put_vector() function (wrapper of GMT API GMT_Put_Vector()) can only pass numerical and datetime vectors/arrays to GMT API
    2. All trailing strings should be passed to GMT API by the GMT_Put_Strings() function (no wrapper for it yet)
    3. You can call GMT_Put_Vectors() multiple times, and pass one vector each time
    4. You can only call GMT_Put_Strings() one time to pass one single string array to GMT

    Thus, to implement this feature, you need to:

    1. wrap the GMT_Put_Strings() function, i.e., put_strings()
    2. pass the leading numerical arrays to GMT via the put_vector() function one by one
    3. Combine all the trailing arrays into one string array, and pass it to GMT via the put_strings() function
    4. Keep your fingers crossed 🤞

    For example, if you want to pass the following arrays to make text() accept input format x, y, angle, justify, font, text:

    x = [5.0, 6.0]
    y = [6.0, 7.0]
    angle = [30, 60]
    justify = ['BL', 'TL']
    font = ['16p,2,blue', '32p,3,red']
    text = ["First label", "Second label"]
    

    You need to:

    1. call put_vectors() three times, passing vectors x, y, angle, respectively
    2. combine the three string arrays to a single one, e.g.,
    new_string = ["BL 16p,2,blue First label", "TL 32p,3,red Second label"]
    
    1. pass the new_string to GMT by calling put_strings()
    2. Again, keep your fingers crossed 🤞
  3. added this to the 0.2.x milestone on Jul 13, 2020
  4. modified the milestones: 0.2.x, v0.3.x on Sep 11, 2020
  5. modified the milestones: 0.3.0, 0.4.0 on Feb 14, 2021
  6. modified the milestones: 0.4.0, 0.5.0 on Jun 18, 2021
  7. modified the milestones: 0.5.0, 0.6.0 on Oct 28, 2021
  8. modified the milestones: 0.6.0, 0.7.0 on Mar 1, 2022
  9. modified the milestones: 0.7.0, 0.8.0 on Jun 23, 2022
  10. modified the milestones: 0.8.0, 0.9.0 on Dec 11, 2022
  11. modified the milestones: 0.9.0, 0.10.0 on Mar 16, 2023
  12. removed this from the 0.10.0 milestone on Aug 24, 2023
  13. seisman commented on Oct 7, 2023

    @seisman
    Member
    1. Pass in a list/array of angle/font/justify values to text (currently only a single angle/font/justify value is allowed, and applied to all texts)

    Will be addressed in PR #2720.

    1. Handle more flexible input formats, e.g., -F+a+j+f and -F+a+f+j (see also Parsing of additional arguments when plotting text from file #479 (comment)).

    Not implemented yet, but better to track it in #479.

    On the non-user facing side, it would be nice too if we can pass the x,y,text input via a virtualfile as mentioned in #321 (comment), instead of a temporary tab-delimited file. This will be a more efficient method of passing data around rather than relying on the pandas.to_csv method. Will need to modify virtualfile_from_vectors to accept str type arrays, see #481 (comment).

    Already done in #559.

    In other words, this issue report will be closed by #2720.

  14. added this to the 0.11.0 milestone on Oct 7, 2023
  15. changed the title [-]Allow passing in a list/array of angle/font/justify values to text[/-] [+]Figure.text: Allow passing in a list/array of angle/font/justify values to text[/+] on Oct 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requesthelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions