Borrar filtros
Borrar filtros

How to customise Polar Plots - Part 2

4 visualizaciones (últimos 30 días)
Sam Hurrell
Sam Hurrell el 28 de Mayo de 2024
Comentada: Sam Hurrell el 1 de Jun. de 2024
Following on from a question I had a year ago (How to customise Polar Plots - MATLAB Answers - MATLAB Central (mathworks.com)), I am in need of shifting the location of the chart/axis titles. My polar plot has a range of 180^o: from-90 to 90 with 0 at the middle bottom, but because I've had to increase the axis fontweight to bold, the Raxis values and label overlap with the chart title. When I try to relocate the chart title horizontally to the left, it is going off the screen. Can someone advise, I've included the relevant code below:
polarplot(th2-pi/2,Rs); Ax = gca; Ax.ThetaZeroLocation = 'bottom'; Ax.ThetaLim = [270 360+90];
Ax.LineWidth = 2; Ax.FontSize = 16; Ax.FontWeight = 'bold'; Ax.RLim = [0 1e-7]; Ax.ThetaTick = Ax.ThetaLim(1):10:Ax.ThetaLim(2);
Ax.RTick = Ax.RLim(1):1e-8:Ax.RLim(2); Ax.ThetaTickLabel = compose('%d',-90:10:90);
title('I want this chart title to be wholly visible in the top-left hand corner of the screen','FontSize',20,'FontWeight','bold');

Respuesta aceptada

Adam Danz
Adam Danz el 28 de Mayo de 2024
Editada: Adam Danz el 30 de Mayo de 2024
Thanks for sharing this, @Sam Hurrell. Something's fishy.
Here's a workaround. You can set the axes' TitleHorizontalAlignment property to left and the title's VerticalAlignment property to Top.
polarplot(rand(1,10),rand(1,10));
Ax = gca;
Ax.ThetaZeroLocation = 'bottom';
Ax.ThetaLim = [270 360+90];
Ax.LineWidth = 2;
Ax.FontSize = 16;
Ax.FontWeight = 'bold';
Ax.RLim = [0 1e-7];
Ax.ThetaTick = Ax.ThetaLim(1):10:Ax.ThetaLim(2);
Ax.RTick = Ax.RLim(1):1e-8:Ax.RLim(2);
Ax.ThetaTickLabel = compose('%d',-90:10:90);
% Workaround:
t = title('Title','FontSize',20,'FontWeight','bold');
Ax.TitleHorizontalAlignment = 'Left';
t.VerticalAlignment = 'top';
Alternatively, use tiledlayout
Tiledlayout uses a different space management system. This demo manually inserts newline characters to break up the long title.
figure('position',[50 50 600 600])
tiledlayout(1,1,'padding','compact')
Ax = nexttile();
polarplot(rand(1,10),rand(1,10));
Ax = gca;
Ax.ThetaZeroLocation = 'bottom';
Ax.ThetaLim = [270 360+90];
Ax.LineWidth = 2;
Ax.FontSize = 16;
Ax.FontWeight = 'bold';
Ax.RLim = [0 1e-7];
Ax.ThetaTick = Ax.ThetaLim(1):10:Ax.ThetaLim(2);
Ax.RTick = Ax.RLim(1):1e-8:Ax.RLim(2);
Ax.ThetaTickLabel = compose('%d',-90:10:90);
% Workaround:
str = ['I want this',newline(),...
'chart title to',newline(),...
'be wholly visible',newline(),...
'in the top-left',newline(),...
'hand corner of',newline(),...
'the screen'];
t = title(str,'FontSize',20,'FontWeight','bold');
Ax.TitleHorizontalAlignment = 'Left';
t.VerticalAlignment = 'middle';
t.HorizontalAlignment = 'left';
  3 comentarios
Adam Danz
Adam Danz el 29 de Mayo de 2024
Editada: Adam Danz el 30 de Mayo de 2024
Try putting it in a tiled layout. I've updated my answer to show how.
Sam Hurrell
Sam Hurrell el 1 de Jun. de 2024
That has solved it, cheers man

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Etiquetas

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by