Davide-sd / sympy-plot-backends

An improved plotting module for SymPy
BSD 3-Clause "New" or "Revised" License
44 stars 10 forks source link

plot_polar incorrect polar curves with negative values of r #12

Closed ZoranGitHub closed 1 year ago

ZoranGitHub commented 1 year ago

Hi Davide-sd, thank you very much for this package. It is greatly appreciated. Works great. One issue I came across is that it does not show correct curves on plot_polar when values of r are negative. As I am using Plotly backend I'll try to explain it for that case. It looks that theta range is passed as values for theta in Scatterpolar in Plotly but that is not correct in every case, specifically when r are negative values. The Jupiter Lab file that explains the problem and shows one of the solutions is attached.

PolarFnCalc.ipynb.zip

It may be good to include rpos=True/False option (rpos is True for r positive only and to be default). There may be some presentations when people want to include negative r.

Also I noticed that plot_parametric with Plotly as a backend does not display values when hovering over it. This may be issue with my installation but please check. Thanks once again and best regards, Zoran

Davide-sd commented 1 year ago

Hello @ZoranGitHub , thanks for pointing this out!

Actually, the plot are all correct... What you are seeing is the polar axis. What I should do is for plot_polar to create cartesian axis, and add an option for polar axis.

Also I noticed that plot_parametric with Plotly as a backend does not display values when hovering over it.

On my installation I'm getting the data when hovering over the points. I'm afraid it's some problem with your environment.

Speaking of problems: I switched to a new machine and Plotly refuses to show grid lines. Have you experienced something similar?

ZoranGitHub commented 1 year ago

Sorry Davide but have to disagree. Polar curves presented in polar plots should be as ones I presented using Plotly. If you compare curves marked by “incorrect”, for the same equation, in plot_polar and Scatterpolar they look different (similar but not the same). And Scatterpolar is correct. Currently I am going through the book”Calculus” by prof Gilbert Strang and what I am getting with Scatterpolar is correct. I think that if you pass values to Scatterpolar in a way I did or equivalent it would be perfect.

Yes, one can always use plot_parametric to get right plot but keeping it polar gives it something special.

Anyway, I really appreciate what you have done so far. All the best, Zoran

PS: No, I haven’t noticed any issues with grid not showing up.

On Mon, 19 Dec 2022 at 12:40 am, Davide Sandonà @.***> wrote:

Hello @ZoranGitHub https://github.com/ZoranGitHub , thanks for pointing this out!

Actually, the plot are all correct... What you are seeing is the polar axis. What I should do is for plot_polar to create cartesian axis, and add an option for polar axis.

Also I noticed that plot_parametric with Plotly as a backend does not display values when hovering over it.

On my installation I'm getting the data when hovering over the points. I'm afraid it's some problem with your environment.

Speaking of problems: I switched to a new machine and Plotly refuses to show grid lines. Have you experienced something similar?

— Reply to this email directly, view it on GitHub https://github.com/Davide-sd/sympy-plot-backends/issues/12#issuecomment-1356833773, or unsubscribe https://github.com/notifications/unsubscribe-auth/AR5EELFGTMLPJFCSG36A7N3WN4475ANCNFSM6AAAAAATCQ4J7A . You are receiving this because you were mentioned.Message ID: @.***>

ZoranGitHub commented 1 year ago

Hi Davide, From the sympy backend perspective you are right, whatever sympy plot_polar shows will be on the backend and you have done your work perfectly. So, it is more an issue with sympy plot_polar limitations and may be it should be raised with the sympy people.

Anyway, thanks and keep up the excellent work. Regards, Zoran

---------- Forwarded message --------- From: Zoran Vucic @.> Date: Mon, 19 Dec 2022 at 1:08 am Subject: Re: [Davide-sd/sympy-plot-backends] plot_polar incorrect polar curves with negative values of r (Issue #12) To: Davide-sd/sympy-plot-backends < @.>

Sorry Davide but have to disagree. Polar curves presented in polar plots should be as ones I presented using Plotly. If you compare curves marked by “incorrect”, for the same equation, in plot_polar and Scatterpolar they look different (similar but not the same). And Scatterpolar is correct. Currently I am going through the book”Calculus” by prof Gilbert Strang and what I am getting with Scatterpolar is correct. I think that if you pass values to Scatterpolar in a way I did or equivalent it would be perfect.

Yes, one can always use plot_parametric to get right plot but keeping it polar gives it something special.

Anyway, I really appreciate what you have done so far. All the best, Zoran

PS: No, I haven’t noticed any issues with grid not showing up.

On Mon, 19 Dec 2022 at 12:40 am, Davide Sandonà @.***> wrote:

Hello @ZoranGitHub https://github.com/ZoranGitHub , thanks for pointing this out!

Actually, the plot are all correct... What you are seeing is the polar axis. What I should do is for plot_polar to create cartesian axis, and add an option for polar axis.

Also I noticed that plot_parametric with Plotly as a backend does not display values when hovering over it.

On my installation I'm getting the data when hovering over the points. I'm afraid it's some problem with your environment.

Speaking of problems: I switched to a new machine and Plotly refuses to show grid lines. Have you experienced something similar?

— Reply to this email directly, view it on GitHub https://github.com/Davide-sd/sympy-plot-backends/issues/12#issuecomment-1356833773, or unsubscribe https://github.com/notifications/unsubscribe-auth/AR5EELFGTMLPJFCSG36A7N3WN4475ANCNFSM6AAAAAATCQ4J7A . You are receiving this because you were mentioned.Message ID: @.***>

Davide-sd commented 1 year ago

I've just released a new version in which I think I solved the issue. Take a look and let me know.

ZoranGitHub commented 1 year ago

Hi Davide, Noticed it on your website before I saw your email. Yes, upgraded the package and looks excellent. Thank you very much. I’ll do some further testing but do not see a reason why it wouldn’t work.

Best regards, Zoran

PS: By the way, still have a problem with hover over plot_parametric with Plotly backend (Mac and Dell with Windows 10). Not a big issue but if you come across some potential solution please let me know.

On Tue, 20 Dec 2022 at 3:03 am, Davide Sandonà @.***> wrote:

I've just released a new version in which I think I solved the issue. Take a look and let me know.

— Reply to this email directly, view it on GitHub https://github.com/Davide-sd/sympy-plot-backends/issues/12#issuecomment-1358116624, or unsubscribe https://github.com/notifications/unsubscribe-auth/AR5EELF776ALQZMYGV4MWQTWOCWOZANCNFSM6AAAAAATCQ4J7A . You are receiving this because you were mentioned.Message ID: @.***>

Davide-sd commented 1 year ago

PS: By the way, still have a problem with hover over plot_parametric with Plotly backend (Mac and Dell with Windows 10). Not a big issue but if you come across some potential solution please let me know.

Unfortunately, I don't use Windows. However, I tested the output of plot_parametric on Ubuntu with Firefox and Chrome, both with use_cm=True and use_cm=False: tooltip is visible when hovering over points. I'm using Plotly 5.11.0.