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

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

Closed
weiji14 opened this issue Jun 21, 2020 · 2 comments · Fixed by #2720
Closed

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

weiji14 opened this issue Jun 21, 2020 · 2 comments · Fixed by #2720
Labels
feature request New feature wanted help wanted Helping hands are appreciated
Milestone

Comments

@weiji14
Copy link
Member

weiji14 commented Jun 21, 2020

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 😄

@weiji14 weiji14 added help wanted Helping hands are appreciated feature request New feature wanted labels Jun 21, 2020
@seisman
Copy link
Member

seisman commented Jun 22, 2020

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 🤞

@weiji14 weiji14 mentioned this issue Jul 13, 2020
5 tasks
@weiji14 weiji14 added this to the 0.2.x milestone Jul 13, 2020
@weiji14 weiji14 mentioned this issue Sep 6, 2020
11 tasks
@weiji14 weiji14 modified the milestones: 0.2.x, v0.3.x Sep 11, 2020
@seisman seisman modified the milestones: 0.3.0, 0.4.0 Feb 14, 2021
@weiji14 weiji14 modified the milestones: 0.4.0, 0.5.0 Jun 18, 2021
@weiji14 weiji14 modified the milestones: 0.5.0, 0.6.0 Oct 28, 2021
@weiji14 weiji14 modified the milestones: 0.6.0, 0.7.0 Mar 1, 2022
@seisman seisman modified the milestones: 0.7.0, 0.8.0 Jun 23, 2022
@seisman seisman modified the milestones: 0.8.0, 0.9.0 Dec 11, 2022
@seisman seisman modified the milestones: 0.9.0, 0.10.0 Mar 16, 2023
@weiji14 weiji14 removed this from the 0.10.0 milestone Aug 24, 2023
@seisman
Copy link
Member

seisman commented Oct 7, 2023

  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.

@seisman seisman added this to the 0.11.0 milestone Oct 7, 2023
@seisman seisman 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 Oct 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature wanted help wanted Helping hands are appreciated
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants