Skip to content

Feature: stem3D to generate 3D stem plots #15253

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

Closed
wants to merge 2 commits into from

Conversation

harshanavkis
Copy link

This commit introduces the stem3D function. It is similar to the stem3
function from Matab.

Resolves Issue #15066.

Signed-off-by: harshanavkis harshanavkis@gmail.com

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

Copy link
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the PR! Please check the signature, and if possible add an example for the gallery.

Feel free to ask here if you have any questions.

When plotting 2D data, the direction to use as z ('x', 'y'
or 'z'); defaults to 'z'.
**kwargs
Other arguments are forwarded to matplotlib.axes.Axes.stem
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please link:

Suggested change
Other arguments are forwarded to matplotlib.axes.Axes.stem
Other arguments are forwarded to `matplotlib.axes.Axes.stem`.

if args and not isinstance(args[1], str):
xs, ys, *args = args
if 'xs' in kwargs:
raise TypeError("""stem() for multiple values for argument
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be simplified to

                    raise TypeError(
                        "stem() for multiple values for argument 'x'")

@@ -1418,6 +1418,56 @@ def text(self, x, y, z, s, zdir=None, **kwargs):
text3D = text
text2D = Axes.text

def stem(self, zs, zdir='z', *args, **kwargs):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function should support a call of the form

stem(x, y, z, zdir='y')

That seems not to be possible with the current signature. I think

def stem(x, y, z, *, zdir='z', **kwargs):

should be sufficient. In contrast to 1D, there is no canonical ordering of a sequence of values. However, if you want to fully mimic the MATLAB API, you'd have to use

def stem(*args, zdir='z', **kwargs):

But I would want to see some tests that this more complicated API actually behaves reasonable.

@harshanavkis
Copy link
Author

Should I add an example to examples/mplot3d/ showing its usage?

This commit introduces the stem3D function. It is similar to the stem3
function from Matab.

Resolves Issue matplotlib#15066.

Signed-off-by: harshanavkis <harshanavkis@gmail.com>
@timhoffm
Copy link
Member

Yes, please.

This commit provides an example on generating 3d stem plots.

Resolves Issue matplotlib#15066.

Signed-off-by: harshanavkis <harshanavkis@gmail.com>
@harshanavkis
Copy link
Author

harshanavkis commented Sep 13, 2019

There seems to be a problem with projecting the 2d stem to a 3d stem. How can I resolve this? stem() returns a StemContainer object. Is there another *2d_to_3d function? Should I write a new one?

@timhoffm
Copy link
Member

duplicate: #15264

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants