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

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

Closed
yvonnefroehlich opened this issue Sep 10, 2022 · 10 comments · Fixed by #7025
Closed
Labels
bug Something isn't working

Comments

@yvonnefroehlich
Copy link
Member

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
@PaulWessel
Copy link
Member

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.

@PaulWessel
Copy link
Member

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?

@yvonnefroehlich
Copy link
Member Author

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.

PaulWessel added a commit that referenced this issue Sep 12, 2022
See #7021 for backtround.  This PR adds some language to indicate the multiband values should be sorted if +v is used.  Closes #7021.
@seisman
Copy link
Member

seisman commented Sep 13, 2022

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

@PaulWessel
Copy link
Member

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?

@PaulWessel
Copy link
Member

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

@seisman
Copy link
Member

seisman commented Sep 13, 2022

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.

@PaulWessel
Copy link
Member

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

@joa-quim
Copy link
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.

@yvonnefroehlich
Copy link
Member Author

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).

PaulWessel added a commit that referenced this issue Sep 21, 2022
See #7021 for backtround.  This PR adds some language to indicate the multiband values should be sorted if +v is used.  Closes #7021.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants