Borrar filtros
Borrar filtros

Change the style of the lines/grids in polar plot

9 visualizaciones (últimos 30 días)
Yang Hu
Yang Hu el 29 de Oct. de 2023
Comentada: Yang Hu el 30 de Oct. de 2023
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]);

Respuesta aceptada

Francesco
Francesco el 29 de Oct. de 2023
Editada: Francesco el 29 de Oct. de 2023
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

Más respuestas (0)

Categorías

Más información sobre Polar Plots en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by