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

Plot: labelling multiple expressions at once #22609

Open
jondo opened this issue Dec 5, 2021 · 1 comment
Open

Plot: labelling multiple expressions at once #22609

jondo opened this issue Dec 5, 2021 · 1 comment
Labels

Comments

@jondo
Copy link
Contributor

jondo commented Dec 5, 2021

With SymPy 1.9, the code

import sympy as sp
x = sp.Symbol('x')
f = x
g = 2*x

p = sp.plot(f, g, label=('f','g'), show=False)
p.legend = True
p.show()

gives:
Screenshot from 2021-12-05 16-14-00

It might be more useful in this case if the elements of the label argument were used as separate labels for the printed expressions.

The current workaround is

p = sp.plot(f, label='f', show=False)
p2 = sp.plot(g, label='g', show=False)
p.append(p2[0])
p.legend = True
p.show()

This creates the expected
Screenshot from 2021-12-05 16-19-01

This issue is similar to @Davide-sd 's #21300.

@NikhilSDate
Copy link
Contributor

It seems like there is already a pull request (#21302) linked with #21300, but it is still open. I might be wrong here, but it seems like that pull request changes things so that the label has to specified along with the expression to be plotted in a tuple. I feel that the approach mentioned in this issue (providing the labels as a separate argument) is a bit cleaner. If it is worthwhile to fix this issue, I would be happy to work on this issue, but I'm not sure if a fix is needed in the first place. Any thoughts?

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

No branches or pull requests

3 participants