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

 Submitted by: None Submitted on: 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

You are not logged in

Discussion

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>
Sun 09 Dec 2018 11:40:02 PM UTC, comment #6:

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>
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>
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:

Anonymous

Attached Files

(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)

Dependencies

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)
•

Do you think this task is very important?
This task has 0 encouragements so far.

Only project members can vote.