Polar grid lines on a Cartesian scatterplot

I have a script to create scatterplots (using gscatter ) based on xy data (discrete data points, not continuous) created by another script. Since these data points are actually the locations of certain objects in circular space, adding polar grid lines will make the graphs more meaningful.

Does anyone know how to show polar grid lines on a Cartesian scatterplot, or am I better off using polar plots?

+4
source share
2 answers

You can always use the pol2cart function to generate polar grid lines. For instance:

 function DrawGridLines x = randn(10); y = randn(10); figure;scatter(x(:),y(:)); hold on ; for angle = 0:20:(360-20) [x1,y1] = pol2cart( angle / 180 * pi , [0 2]); plot(x1,y1,'r') end for rho = 0:0.1:2 [x1,y1] = pol2cart( 0:0.01:2*pi , rho); plot(x1,y1,'b') end axis equal end 

enter image description here

+2
source

I once made this script to draw a polar coordinate system on top of a regular graph. Perhaps this may be useful for you. It is based on this script, but simplified to only draw a coordinate system and no data. If this is not what you were looking for, check out the related script, maybe it can also help.

Be sure to adjust the radius as necessary! I usually turn off the axis, but it's up to you if you need a different look :)

 R=6000; %radius S=10; %num circ.lines N=10; %num ang.lines sect_width=2*pi/N; offset_angle=0:sect_width:2*pi-sect_width; %------------------ r=linspace(0,R,S+1); w=0:.01:2*pi; clf %remove if needed hold on axis equal for n=2:length(r) plot(real(r(n)*exp(j*w)),imag(r(n)*exp(j*w)),'k--') end for n=1:length(offset_angle) plot(real([0 R]*exp(j*offset_angle(n))),imag([0 R]*exp(j*offset_angle(n))),'k-') end %------------------ 

Result from script

+2
source

Source: https://habr.com/ru/post/1393117/


All Articles