フィルターのクリア

How to customise Polar Plots - Part 2

4 ビュー (過去 30 日間)
Sam Hurrell
Sam Hurrell 2024 年 5 月 28 日
コメント済み: Sam Hurrell 2024 年 6 月 1 日
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');

採用された回答

Adam Danz
Adam Danz 2024 年 5 月 28 日
編集済み: Adam Danz 2024 年 5 月 30 日
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 件のコメント
Adam Danz
Adam Danz 2024 年 5 月 29 日
編集済み: Adam Danz 2024 年 5 月 30 日
Try putting it in a tiled layout. I've updated my answer to show how.
Sam Hurrell
Sam Hurrell 2024 年 6 月 1 日
That has solved it, cheers man

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePolar Plots についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by