필터 지우기
필터 지우기

Change the style of the lines/grids in polar plot

조회 수: 9 (최근 30일)
Yang Hu
Yang Hu 2023년 10월 29일
댓글: Yang Hu 2023년 10월 30일
Hi everyone, I want to edit the style of the grid/line in a polar plot to make them more visible. But I am having trouble with my current sloppy code. The grids/lines are not showing up as they are supposed to.
clc
clear
A = readmatrix('male_nuclei_control.xlsx');
angle = A(:,5);
figure;
pax = polaraxes; %https://www.mathworks.com/help/matlab/ref/thetalim.html
thetalim('auto');
AR = A(:,6);
th = deg2rad(angle);
r = AR;
sz = 100;
c = 'k';% change color based on need, purple [.5 0 .5]
facecolor = [1 .5 0];% set face color to fill dots, orange [1 .5 0];
polarscatter(pax,th,r,sz,c,'LineWidth',1.5,'MarkerFaceColor',facecolor, 'visible', 'on');% if the circles not needed to be filled, delete it
% if need to be filled, type 'filled' after c
set(gca,'color',[.7 .7 .7 0.5]);% set background color [.7 .7 .7] is grey, [.7 .7 .7 0.5} is 50% transparent grey
pax.GridColor = 'k';
pax.Layer = 'top';
% polarscatter(th,r,sz,c,'LineWidth',1.5);% if the circles not needed to be filled, delete it
% if need to be filled, type 'filled' after c
thetalim(pax,[0 180]);
% pax = gca;% redefine font size
pax.FontSize = 18;% redefine font size
set(gcf, 'Position', [50, 100, 800, 400]);

채택된 답변

Francesco
Francesco 2023년 10월 29일
편집: Francesco 2023년 10월 29일
Hi,
I am not sure I fully understand the question, but you could try altering the "LineWidth" and "GridAlpha" properties for the polar axes to make the grid more visible. I tried tweaking your code with the following settings inserted after line 24:
pax.LineWidth = 4;
pax.GridAlpha = .5;
and I think the grid looks much clearer now.
To change the line style you need to to set the "GridLineStyle" properties as desired. See the documentation on polar axes appearence and behavior: https://www.mathworks.com/help/matlab/ref/matlab.graphics.axis.polaraxes-properties.html
  댓글 수: 1
Yang Hu
Yang Hu 2023년 10월 30일
yes, this is exactlly what I am looking for, thank you.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Polar Plots에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by