-
Notifications
You must be signed in to change notification settings - Fork 224
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.plot: Add the "symbol" parameter to support plotting data points with varying symbols #1117
Merged
seisman
merged 19 commits into
GenericMappingTools:main
from
core-man:plot-1d-array-symbol
Oct 29, 2024
Merged
Changes from 9 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
41a9e6a
Add test_plot_symbols.png into DVC
core-man ebeabea
Allow passing an array as symbols for plot
core-man c922870
Add tests for 1d-array symbols for plot
core-man 54db5e8
Merge branch 'master' into plot-1d-array-symbol
core-man 4a4ae08
Merge branch 'master' into plot-1d-array-symbol
core-man 1c48b39
Automactically set style to True if symbol is used
core-man 199f861
Update test_plot_symbols.png
core-man 3d97972
Update test_plot_symbols
core-man 0861741
Merge branch 'master' into plot-1d-array-symbol
core-man 0675acb
Merge branch 'main' into plot-1d-array-symbol
seisman 9f136c8
Merge branch 'main' into plot-1d-array-symbol
seisman ab2a9da
Fix comment in tests
seisman 17f7cc7
Add one more comment
seisman 02ebc94
Add a new baseline image
seisman ecd0395
Fix the order
seisman 0e1e15a
Merge branch 'main' into plot-1d-array-symbol
seisman 4dc2e1c
Merge branch 'main' into plot-1d-array-symbol
seisman 45cf127
Fix styling
seisman 21b36f7
Merge branch 'main' into plot-1d-array-symbol
seisman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
outs: | ||
- md5: 394a4e806a99234f239437252a99254c | ||
size: 13759 | ||
path: test_plot_symbols.png |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,19 +91,23 @@ def test_plot_fail_no_data(data): | |
) | ||
|
||
|
||
def test_plot_fail_color_size_intensity(data): | ||
def test_plot_fail_1d_array_using_data(data): | ||
""" | ||
Should raise an exception if array color, sizes and intensity are used with | ||
matrix. | ||
Should raise an exception if array color, sizes, intensity and symbol are | ||
used with matrix. | ||
""" | ||
fig = Figure() | ||
kwargs = dict(data=data, region=region, projection="X10c", frame="afg") | ||
with pytest.raises(GMTInvalidInput): | ||
fig.plot(style="c0.2c", color=data[:, 2], **kwargs) | ||
with pytest.raises(GMTInvalidInput): | ||
fig.plot(style="cc", sizes=data[:, 2], color="red", **kwargs) | ||
fig.plot(style="cc", color="red", sizes=data[:, 2], **kwargs) | ||
with pytest.raises(GMTInvalidInput): | ||
fig.plot(style="c0.2c", color="red", intensity=data[:, 2], **kwargs) | ||
with pytest.raises(GMTInvalidInput): | ||
fig.plot( | ||
style="0.2c", color="red", symbol=np.full(len(data[:, 2]), "c"), **kwargs | ||
) | ||
|
||
|
||
@pytest.mark.mpl_image_compare | ||
|
@@ -295,6 +299,25 @@ def test_plot_sizes_colors_transparencies(): | |
return fig | ||
|
||
|
||
@pytest.mark.mpl_image_compare | ||
def test_plot_symbols(data, region): | ||
""" | ||
Plot the data using array-like symbols. | ||
""" | ||
fig = Figure() | ||
fig.plot( | ||
x=data[:, 0], | ||
y=data[:, 1], | ||
region=region, | ||
projection="X4c", | ||
color="blue", | ||
sizes=np.full(len(data[:, 0]), 0.5), | ||
symbol=np.full(len(data[:, 0]), "c"), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At the moment, this test is checking that plotting all symbols as circles (c) work. A better test would be to test a mix of symbols such as circles (c), triangles (t), squares (s), etc (like your example in #1076 (comment)). |
||
frame="af", | ||
) | ||
return fig | ||
|
||
|
||
@pytest.mark.mpl_image_compare | ||
def test_plot_matrix(data): | ||
""" | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added
isinstance(kwargs["S"], str)
in case that thestyle
parameter is True, False, None, int, or float.