bugGNU Octave - Bugs: bug #55176, polar plot does not plot rho axis...

 
 

bug #55176: polar plot does not plot rho axis correctly for negative rho values

Submitter:  None
Submitted:  Thu 06 Dec 2018 11:37:59 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  None
Status:  Works For Me Assigned to:  None
Originator Name:  Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 4.4.1
Operating System:  * Any Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Mon 10 Dec 2018 10:29:29 PM UTC, comment #8: 

Ok so its expected behaviour that cannot be altered. Somewhat unfortunate as plotting antenna patterns is the only time I use polar plots and I was trying to avoid resorting to Excel to do this. I think it is a reasonable use case that could be considered as an improvement.

Anonymous
Mon 10 Dec 2018 12:39:50 AM UTC, comment #7: 

Octave is doing the correct thing here.  When rho is negative it amounts to a reflection back through the origin or the addition of 180 degrees to theta. 

Matlab's documentation is very clear on this: https://www.mathworks.com/help/matlab/ref/polar.html.


Negative r values reflect through the origin, rotating by pi (since (theta,r) transforms to (r*cos(theta), r*sin(theta))). If you want different behavior, you can manipulate r prior to plotting. For example, you can make r equal to max(0,r) or abs(r).


It seems like you can achieve what you want by transforming rho prior to plotting.


## Assuming rho and theta exist
offset = -45;  # taken from your data, you could also use min (rho(:));
rhoplot = rho - offset;
h = polar (theta, rhoplot);


The labeling would be off.  You could fix that too, but that would involve adding your own text labels.  You could copy the code in polar.m to doo that, but probably more than you want to do.

Eventually Octave needs to implement polarplot and polaraxes as a separate base graphics type.  polaraxes have an "rticklabel" property that can be set to whatever you want.

Rik <rik5>
Group administrator
Sun 09 Dec 2018 11:40:02 PM UTC, comment #6: 

Please send us your program and data, so that we can help you.

Doug Stewart <dastew>
Sun 09 Dec 2018 11:30:30 PM UTC, comment #5: 

It seems I didn't articulate clearly enough the issue. Please find attached two plots showing the same data for a gaussian antenna pattern. The plot in Excel shows what I want, and the plot in Octave shows what Octave generates for the same data. I could not see a way to set the rtick labels/range to give the same result as Excel.


Anonymous
Sun 09 Dec 2018 03:47:12 PM UTC, comment #4: 

Unable to reproduce.  Closing report.

Rik <rik5>
Group administrator
Fri 07 Dec 2018 11:07:41 AM UTC, comment #3: 

Works for me.
Ubuntu 18.04 and
octave

>> version

ans = 4.4.1

Doug Stewart <dastew>
Fri 07 Dec 2018 06:08:52 AM UTC, comment #2: 

Seems to work on a very stripped down example.  I tried


h = polar ([0, pi/2], [-1, -2], 'x');
set (h, 'markersize', 10)


See the attached plot where the negative rho values are in the correct location.



Rik <rik5>
Group administrator
Thu 06 Dec 2018 11:41:23 PM UTC, comment #1: 

Hmm, text got lost somehow. Example is:


clf;
theta = linspace (0,2*pi,1000);
rho = sin (7*theta);
polar (theta, rho);
title ("polar() plot");


Negative values of rho appear to be plotted in the centre. In particular this means its impossible to plot antenna patterns which typically have negative gains (i.e. rho values) at many angles (i.e. theta values). Attempting to set the axis does not work either. Note this does not appear to work in Matlab either.

Anonymous
Thu 06 Dec 2018 11:37:59 PM UTC, original submission:  

bug #53999 solution claims to have fixed plotting of negative rho values however a simple example (provided with polar.m!) shows this not to be the case:


clf;
theta = linspace (0,2*pi,1000);
rho = sin (7*theta);
polar (theta, rho);
title ("polar() plot");
+verbatim+

Negative values of rho appear to be plotted in the centre. In particular this means its impossible to plot antenna patterns which typically have negative gains (i.e. rho values) at many angles (i.e. theta values). Attempting to set the axis does not work either. Note this does not appear to work in Matlab either.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #45611:  Gaussian Excel Polar Plot.png added by None (47KiB - image/png)
file #45612:  Gaussian Octave Polar Plot.png added by None (26KiB - image/png)
file #45591:  negpolar.png added by rik5 (25KiB - image/png)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by dastew (Posted a comment)
  • -email is unavailable- added by rik5 (Updated the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-12-09 None Attached File- Added Gaussian Excel Polar Plot.png, #45611
        Attached File- Added Gaussian Octave Polar Plot.png, #45612
    2018-12-09 rik5 Open/ClosedOpen Closed
    2018-12-07 rik5 Attached File- Added negpolar.png, #45591
        StatusNone Works For Me

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code