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

No grid for min values in polar plots #1730

Closed
ffteja opened this issue Feb 1, 2013 · 12 comments
Closed

No grid for min values in polar plots #1730

ffteja opened this issue Feb 1, 2013 · 12 comments
Assignees
Milestone

Comments

@ffteja
Copy link
Contributor

ffteja commented Feb 1, 2013

Grid ylines and ticks are not drawn for y <= 0 in polar plots

Ex :
no grid for min values in polar plots

The bug is true in matplotlib 1.1.1 and 1.2.0. Thanks.

from matplotlib.pyplot import figure, show
import numpy as np

x = np.arange(0,7,0.001)
y = np.arange(-2.0,5.0, 0.001)
fig = figure()

ax = fig.add_subplot(111, polar=True)
ax.plot(x, y)
ax.autoscale_view(True,True,True)

fig.show()
raw_input()

@pelson
Copy link
Member

pelson commented Feb 4, 2013

Confirmed, but just to be completely explicit, removing the ax.autoscale_view(True,True,True) fixes the problem. Is there a specific thing you are trying to achieve that means ax.autoscale_view(True,True,True) is necessary?

Cheers,

@ffteja
Copy link
Contributor Author

ffteja commented Feb 4, 2013

It doesn't fix the problem. It just plots only positive Y values.

Replace
ax.autoscale_view(True,True,True)
by
ax.set_ylim(-2,5)
and the problem is still here

The problem is there is no Y gridlines for negatives values. (I want to plot a polar plot of negatives values ex: -20dB, -23dB....)

@pelson
Copy link
Member

pelson commented Feb 6, 2013

Apologies, I mis-read the ticket. To me, this is not a bug - I would not expect a polar plot to draw negative tickmarks/gridlines - you will end up with irregularly spaced lines, and will be unable to determine the radial value of any of the plotted points (because, if you plot negative radii r == -r).

Personally, I don't think this feature should be implemented in mpl.

You could achieve a similar goal if all you want is negative radii - in which case, I would just define a formatter which returns the negative of the number it is given. I'd be happy to give you an example of that if you need.

Cheers,

@WeatherGod
Copy link
Member

Or, perhaps, just have the radial axis be set to a log scale and use the
raw (non-negative) values for plotting?

@ffteja
Copy link
Contributor Author

ffteja commented Feb 7, 2013

WeatherGod : Plotting dB was maybe a bad example. The main use is not to plot log scale.

pelson : This ticket is the follow up of #1603. So I guess there is no r = -r issue anymore ?

To my mind : The center of the polar plot r =0 is the minY from autoscale or the set_ylim. And the rmax is the maxY is from autoscale or the set_ylim. Values are plotted correctly. I don't understand why the grid cannot?

For example, I don't know if it's the good way, but mpl could internally shift all values from (-2,5) to (0,7), plot the graph, so values and grid lines are plotted, and shift backwards the ticks to print correct values. This solution is a hack but it works without user interaction. In my case, I can know before if the values I will plot will have negatives values or not.

@ffteja
Copy link
Contributor Author

ffteja commented Feb 22, 2013

pelson : I think your workaround is not possible is you want to plot negative values and positive values on the same graph, isn't it?

@tacaswell
Copy link
Member

This is related to #2203 and #1847

There seems to be some confusion about how to deal with negative r and polar plots. Someone(s) who regularly uses these plots (and preferably someone who plots decibels) needs to weight in on the 'right' way for them to behave.

We now have at least four open issues (and at least one closed one) on this problem.

@tacaswell tacaswell added this to the v1.4.0 milestone Mar 4, 2014
@endolith
Copy link
Contributor

Can someone re-explain why they think this shouldn't be implemented? I don't understand the objection. This is a very common thing to do, like microphone response plots or antenna radiation patterns:

http://w4rnl.net46.net/img/amod48-4a.gif
https://2.bp.blogspot.com/-cDB2d6YCMtc/TzPXIaWFeBI/AAAAAAAAAEM/0mOvOJvKNaU/s1600/SM58%20Polar%20Pattern.jpg
http://learningexchange.ptc.com/tutorials/tutorial_212/Figure09.png
http://www.mathworks.de/matlabcentral/fileexchange/screenshots/3824/original.jpg
http://static.musiciansfriend.com/derivates/6/001/204/424/DV019_Jpg_Regular_271281_polar_pattern.jpg

Faking it by creating a formatter seems needlessly complicated, especially since the plot itself works fine.

@efiring
Copy link
Member

efiring commented Apr 19, 2014

I agree that we should be able to make these db plots without any fuss. All that is needed is an appropriate Locator (and Formatter, if you want to include the "db" labels). The default RadialLocator is appropriate for ordinary polar coordinates. One can replace it with a MaxNLocator, or anything else. A potential problem with existing locators for this purpose is that they might tend to put a tick and label at or too close to the actual center.

@tacaswell
Copy link
Member

@ffteja @endolith I have created a MEP for this (https://github.com/matplotlib/matplotlib/wiki/MEP24) and would like your input on it.

Realistically, there is no way this is going to get done for 1.4, punting to 1.5.x.

@tacaswell tacaswell modified the milestones: v1.5.x, v1.4.0 Jun 29, 2014
@ffteja
Copy link
Contributor Author

ffteja commented May 11, 2015

Hi tacaswell.
Any update on the topic since?

@tacaswell
Copy link
Member

No one (that I am aware of) has shown interest in implementing this.

The MEP has moved to http://matplotlib.org/devdocs/devel/MEP/MEP24.html / https://github.com/matplotlib/matplotlib/tree/master/doc/devel/MEP which still needs to be fleshed out.

@QuLogic QuLogic mentioned this issue Jul 15, 2015
3 tasks
@QuLogic QuLogic self-assigned this Nov 15, 2016
@story645 story645 moved this from In Progress to Issues in Polar Overhaul Apr 14, 2017
@QuLogic QuLogic moved this from Issues to Done in Polar Overhaul Aug 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

8 participants