Skip to content

Handling plotting functions that have an inquire (I) only mode #896

Open

Description

@weiji14

Description of the issue

There are a few GMT modules that have a mode for extracting data (statistics or otherwise) via the inquire (I) flag in addition to plotting:

How do we want to handle these cases? It seems weird to use fig.histogram(..., inquire=...) if no figure/plot is actually returned. One suggestion made at #794 (review) was:

Ideally, what we might have to do is make two user-facing rose functions:

1. A plotting-only `fig.rose`

2. A non-plotting `pygmt.rose` which will solely use the inquire (I) flag.

Both of these could share a core def _rose() function and live within pygmt/src/rose.py. This is just an idea though, and probably quite hard to implement in one Pull Request. For now, we could implement just the plotting side (1) and raise a NotImplementedError for inquire (I), and perhaps wrap pygmt.rose (2) in a future PR? Or maybe there's a smarter alternative way.

Open to suggestions on how we want the API for this look like.

Are you willing to help implement and maintain this feature? Discuss first

Activity

  1. added
    question
    on Feb 15, 2021
  2. michaelgrund commented on Feb 18, 2021

    @michaelgrund
    Member

    How do we want to handle these cases? It seems weird to use fig.histogram(..., inquire=...) if no figure/plot is actually returned.

    I totally agree that it feels quite strange if no plotting object is returned when applying these modules.

    One suggestion made at #794 (review) was:

    Ideally, what we might have to do is make two user-facing rose functions:

    1. A plotting-only `fig.rose`
    
    2. A non-plotting `pygmt.rose` which will solely use the inquire (I) flag.
    

    Both of these could share a core def _rose() function and live within pygmt/src/rose.py. This is just an idea though, and probably quite hard to implement in one Pull Request. For now, we could implement just the plotting side (1) and raise a NotImplementedError for inquire (I), and perhaps wrap pygmt.rose (2) in a future PR? Or maybe there's a smarter alternative way.

    Sounds like a good compromise, however, does it make sense for all modules that have the -I flag or only for a few of them?

  3. weiji14 commented on Feb 28, 2021

    @weiji14
    MemberAuthor

    Sounds like a good compromise, however, does it make sense for all modules that have the -I flag or only for a few of them?

    As far as I can tell, it's only 3 modules (rose, solar and histogram) where this applies. For other modules, the -I flag means something else (e.g. spacing) and not 'inquire'.

  4. seisman commented on Sep 3, 2021

    @seisman
    Member

    Please note that there are more plotting modules that can "dump" something to a file without plotting anything:

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

    question

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions