Skip to content

Unclear bar plot (-Sb or -SB) generated by plot when only appending +v (no +s) #7021

Closed

Description

@yvonnefroehlich

Description of the problem

Please see the explanation to plot vertical and horizontal bars in the GMT documentation of the plot module, especially the following part (exemplary for horizontal bars):

Here, +i means we must accumulate the bar values from the increments dx, while +v means we get the complete values relative to base. Normally, the bands are plotted as sections of a final single bar. Use +s to instead split the bar into nx side-by-side, individual and thinner bars.

What is the expected bar plot (-Sb or -SB ) for only appending +v (no +s), maybe overlaid bars?
This question arises since the generated figure shown below remains unclear, especially for the lower bar. In the case of overlaid bars, three differently colored sections seem to make sense for the upper bar, since two of the four values for this bar are identical. The lower bar contains only three differently colored sections, despite four different values are given in the provided txt file. The values are not given in an increasing / a decreasing order.
Opening this issue is related to GenericMappingTools/pygmt#1521 (comment).

Full script that generated the error

Original post at GenericMappingTools/pygmt#1521 (comment).
Related PyGMT example at GenericMappingTools/pygmt#1521 (comment).

Data: data_vhbars.txt
Colormap (please remove the .txt): roma_vhbars.cpt.txt
CLI minimal example:

gmt plot data_vhbars.txt -R0/4/0/3 -JX8c/4c -SB0.75+v4 -Croma_vhbars.cpt -Ba1f1g1 -W1p,black -png vhbars_overlaid

Full error message

No error message occurs.

Actual outcome

vhbars_overlaid

System information

  • Operating system: Windows-10-10.0.19043-SP0
  • GMT version (gmt --version): 6.4.0

Activity

  1. added
    bug
    on Sep 10, 2022
  2. PaulWessel commented on Sep 10, 2022

    @PaulWessel
    Contributor

    Before I look at this, isn't it reasonable that the data need to be sorted from low to high in case of +v since it is cumulative x-values? If I fix the order, I get

    vhbars_overlaid

    We can either state this in the docs or (probably better) do a sort when +v is set ,but seems odd to me to give the data not sorted.

  3. PaulWessel commented on Sep 11, 2022

    @PaulWessel
    Contributor

    I mean, the data and use for this type of symbol might be categorical thinks with different values, and it makes absolutely no sense to me to if the values relative to base are not sorted. What am I misunderstanding here?

  4. yvonnefroehlich commented on Sep 11, 2022

    @yvonnefroehlich
    MemberAuthor

    Thanks for your response @PaulWessel!

    There is nothing wrong with sorting the values before plotting them for this type of symbol or bar plot.

    My example is slightly modified from a planed PyGMT gallery example by @michaelgrund (bottom right panel, using +v without +s), which seems to be based on an example in the GMT documentation. In the PyGMT example, the data is [currently] not sorted before plotting. No remark is stated, that this is partly necessary when using +v. Thus, as suggested by @PaulWessel, I feel comments in the GMT documentation and the example explanation, that users have to sort the data externally when using +v without +s before passing it to the plot module or method [as long this is not done by plot], would avoid confusion.

  5. seisman commented on Sep 13, 2022

    @seisman
    Member

    I don't think it makes sense to required a sorted data. For this example data, it's impossible to sort the two records at the same time.

    0.25 1 0.65 0.4 2.25
    1.25 2 0.5 1.25 0.75
    
  6. PaulWessel commented on Sep 13, 2022

    @PaulWessel
    Contributor

    For +i it is clearly required that the data are in the right order since sorting makes no sense. For +v I fail to see what sort of actual data would come with values in different columns. Maybe I just dont understand the use. Basically, the data given via +i cumulatively sum to give the required comparable input if +v is used. You cannot shuffle columns around. Your example above, is that really an actual data example of just an made-up example to demonstrate the plotting?

  7. PaulWessel commented on Sep 13, 2022

    @PaulWessel
    Contributor

    If anything, I think an error message might be the best option.

  8. seisman commented on Sep 13, 2022

    @seisman
    Member

    Your example above, is that really an actual data example of just an made-up example to demonstrate the plotting?

    This is just an made-up example data. I think for this kind of data, it makes more sense to use +s to plot split bars instead.

  9. PaulWessel commented on Sep 13, 2022

    @PaulWessel
    Contributor

    Yes, but again you probably want split bar number 2 to represent the same data column throughout.

  10. joa-quim commented on Sep 13, 2022

    @joa-quim
    Member

    If I'm guessing right +v plots the bars from last to first, so if values are not sorted some bars will be completely hidden by some other(s). So, yes, data must absolutely be sorted.

  11. yvonnefroehlich commented on Sep 13, 2022

    @yvonnefroehlich
    MemberAuthor

    Thanks for all the thoughts on this topic!

    If I'm guessing right +v plots the bars from last to first, so if values are not sorted some bars will be completely hidden by some other(s).

    Meaning for the data example 0.25 1 0.65 0.4 2.25 the value 0.4 should be hidden by the value 0.65, correct? But looking at the figure above, this seems not the case. There are sections for 2.25 (blue), 0.4 (yellow), and 0.25 (brown).

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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions