-
Notifications
You must be signed in to change notification settings - Fork 213
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
Allow passing an array as symbols for plot #1117
base: main
Are you sure you want to change the base?
Conversation
Therefore, now we can plot different symbols and sizes like this: |
@@ -206,15 +210,18 @@ def plot(self, x=None, y=None, data=None, sizes=None, direction=None, **kwargs): | |||
kind = data_kind(data, x, y) | |||
|
|||
extra_arrays = [] | |||
if "S" in kwargs and kwargs["S"][0] in "vV" and direction is not None: | |||
extra_arrays.extend(direction) | |||
if "S" in kwargs and isinstance(kwargs["S"], str): |
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 the style
parameter is True, False, None, int, or float.
@core-man I think the co-existence of |
Actually, I'd like to fully avoid using the We could remove the |
I believe we need more discussions about what we would like to see about the |
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 comment
The 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)).
@core-man, ok if one of us picks this PR up again? There's been quite a few changes to the |
Description of proposed changes
We can only plot different symbols via the
data
parameter in the plot method. This PR allows passing an array as symbols via the newsymbol
parameter. Meanwhile, we have to setstyle="0.2c"
, or set 1d-array sizes usingstyle=True
andsizes=sizes
. Therefore, we now have four ways to set symbols and sizes, e.g.,style="c0.5c"
style="cc"
+sizes=sizes
style="0.5c"
+symbol=symbol
style=True
+sizes=sizes
+symbol=symbol
Two tests are added:
test_plot_fail_1d_array_using_data
: RaiseGMTInvalidInput
ifsymbol
is used withdata
parameter. Actually, I renametest_plot_fail_color_size_intensity
to be this test function since we should raise such an error for 1d-arraycolor
,size
,intensity
andsymbol
parameters if they are used with thedata
parameter. (originally posted in The transparency parameter of plot/plot3d methods can be 1d array #1098 (comment))test_plot_symbols
: test 1d-arraysymbol
(all are"c"
) withstyle="0.5c"
.Related #1076
Reminders
make format
andmake check
to make sure the code follows the style guide.doc/api/index.rst
.Slash Commands
You can write slash commands (
/command
) in the first line of a comment to performspecific operations. Supported slash commands are:
/format
: automatically format and lint the code/test-gmt-dev
: run full tests on the latest GMT development version