polar/plot incompatibility

Can any one explain the design choise that causes this:
polarscatter(linspace(0,pi*2/3,100).^2,...
linspace(0,pi*2/3,100),...
32,...
linspace(0,pi*2/3,100),'filled')
hold on
plot([-1 1],[1 -1],'m')
Error using newplot
Adding Cartesian plot to polaraxes is not supported.
Error in matlab.graphics.internal.newplotwrapper (line 11)
axReturn = newplot(varargin{:});
From my perspective picking polar/cartesian representation of my grid is just that - a choise of either cartesian grid-lines of polar grid-lines. Why should it not be possible to add objects with cartesian coordinates to a region with polar grid-lines or the other way around?

2 Comments

What version of MATLAB are you using?
Chris: for this it was 2023a

Sign in to comment.

Answers (1)

The original coordinate system predominates, and the subsequent plot call respects that.. You are plotting two points, and .
If you want to plot them as and , you need to transform them --
polarscatter(linspace(0,pi*2/3,100).^2,...
linspace(0,pi*2/3,100),...
32,...
linspace(0,pi*2/3,100),'filled')
hold on
% plot([-1 1],[1 -1],'m')
[r,a] = cart2pol([-1 1],[1 -1]) % Transform To Polar Coordinates
r = 1×2
2.3562 -0.7854
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
a = 1×2
1.4142 1.4142
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
plot(r,a)
figure
plot([-1 1],[1 -1])
axis('equal')
grid
.

13 Comments

That's helpful and all. But my question was about the design choise in having one set of functions for plotting stuff with polar-coordinates and one set of functions for cartesian coordinates (that then trows an error (at least till 2023a) or in newer than 2023a versions change the interpretation of the inputs if there was a polar-coordinates grid in the axes). This design choise has never made any sense to me - grid-lines are just marking a grid.
I believe that is the way MATLAB has always worked. For example, if the first plot is in logarithmic coordinates in any axis, subsequent plots are automatically in the same axes, even if plotted with plot rather than loglog or semilog. It has never been possible to use Cartesian coordinates with polar axes, or overplot one with the other.
True. But for the log-plots they perform a scaling of the axes, and we can add additional points/lines/etc to those plots with that automatic scaling, and then change that scaling/transform to whichever we like. The polar/plot does no such scaling, it is just a difference in polar/cartesian representation of points in the plane. That it's never been possible to automatically combine plotting points with polar and cartesian representatino in one axes has never made sense to me during the 30 years I've used matlab.
Star Strider
Star Strider on 29 Oct 2025
Edited: Star Strider on 29 Oct 2025
That is a design decision you will have to discuss with MathWorks. It makes sense to me, however it would also be nice to be able to 'overlay' cartesian and polar coordinate plots.
Perhaps using images of both and overlaying one on top of the other (with appropriate transparency characteristics) would be an option. That is hardly ideal, however it could be a work-around.
EDIT -- (29 Oct 2025 at 16:42)
One option would be to draw polar coordinates on Cartesian axes, and then draw yoiur Cartesian plot on the same axes. See my original answer in fill area between two polar curves for applicable code for the polar plot in Cartesian axes. (This was before polar patch plots became easily available in the last year or so.)
.
One might as well complain that plotting to a cartesian axes cannot be combined with plotting to a map axes.
Bjorn Gustavsson
Bjorn Gustavsson on 30 Oct 2025
Edited: Bjorn Gustavsson on 30 Oct 2025
@Walter Roberson, that comparison only works for a "flat Earth". The crucial difference is that maps use any of the vast number of map-projections from the spherical/elipsoidal/gaoidal surface to a plane. The polar and cartesian coordinates are two representations of points on a plane.
@Star Strider: that is how I do it when in need for plots with both cartesian and polar plots, but (as lazy as I am) is not the "cleanest" solution. I was hoping for some insight from MathWorks on this because they are the ones making these design choises.
@Bjorn Gustavsson -- Perhaps the best option for that topic is in the Discussions area.
MathWorks design decisions are definitely not a topic that I can comment on with either authority or credibility.
@Star Strider, yeah, somehow I managed to get this thread in the wrong lane. My intension was to add it to the discussions. I have no idea how I ended up making this into an answer (I understand that it's me that muddled it up...). Is it possible to move this discussion from the Answers to the Discussions?
So all that the code would have to do is assume altitude 0 for 2D points, and altitude given by Z for 3D points. Using whichever spherical/elipsoidal/gaoidal is in effect for the axes. This would be entirely consistent with the effect of rotating 2D graphs using hg transforms.
@Bjorn Gustavsson -- It might be easiest to copy the URL of this thread and include it in a discussion that you wnat to post. Everyone can then click on the URL to see it here.
I have read several discussions, however I have never posted to the 'Discussions' site. I am not certain what is involved.
That still doesn't make it exactly the same as points in a cartesian plane, and that part is something I have to insist makes it fundamentally different, to bend lines to adhere to a map-projection...
This chat is an interesting read. I want to make sure I understand the idea: @Bjorn Gustavsson is your curiously about why plot(x,y) interprets the arguments as polar values (theta, radius) when plotting to polar axes rather than sticking to a Cartesian interpretation?
I can see that argument.
plot() is like a swiss army knife. It can take datetime, duration, categorical, and various types of numeric data (e.g. geographical, polar, Cartesian). Plot interprets the inputs based on the axis/ruler type. For example, the first line below creates a datetime ruler for the x-axis. The x-values of the 3rd line are therefore interpreted as durations (number of days).
plot(datetime(2000,1,1:5), 1:5, '-bo')
hold on
plot(1:5, 3:7, '-rd')
Or, is the question about why Euclidean lines are used to connect points in polar space? I've also wondered this. We recently showed how to get around this in a recent article in the Graphics and App Building blog.
I, personally, would like to see an option to connect points in polar space using arch interpolation. I also mentioned this in the following thread:

Sign in to comment.

Categories

Products

Release

R2023b

Tags

Asked:

on 28 Oct 2025

Commented:

on 3 Nov 2025

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!