Adding axes to histogram on scatterhist, and changing graph area

11 ビュー (過去 30 日間)
AeroLad
AeroLad 2020 年 4 月 30 日
編集済み: Adam Danz 2021 年 3 月 25 日
Hello,
I have been trying for quite a while to add an axis with a title and a scale on my scatterhist plot. I have not found any means of doing this yet. Lastly, I have managed to get rid of the x axis histogram, but am unable to get rid of the space that it fomerly occupied. To give an idea of what I am trying to achieve:
The x-axis graph has been deleted with this code:
figure(3)
load data.mat
h = scatterhist(t, distance_totals,'Marker','.','MarkerSize',10,'Color','k','NBins',[15,15])
xlim([0,60]);
ylim([0,150]);
set(gca,'fontsize',12);
xlabel('Time(s)');
ylabel('Distance (m)');
title('Time vs Distance for 100 Iterations')
%annotation('textbox', [0.75, 0.75, 0.1, 0.1],'string', mean(t))
delete(h(2))
Would appreciate any help.
Thanks

採用された回答

Tommy
Tommy 2020 年 4 月 30 日
How about something like this?
figure(3)
h = scatterhist(rand(100,1), rand(100,1),'Marker','.','MarkerSize',10,'Color','k','NBins',[15,15]);
set(gca,'fontsize',12);
xlabel('Time(s)');
ylabel('Distance (m)');
title('Time vs Distance for 100 Iterations');
h(1).Position([2 4]) = [0.13 h(1).Position(4)+h(1).Position(2)-0.13];
h(3).Position([2 4]) = h(1).Position([2 4]);
ax = axes('Position', h(3).Position,...
'Color', 'none',...
'YColor', 'none',...
'XAxisLocation', 'top',...
'XLim', h(3).YLim);
xlabel(ax, 'xlabel');
delete(h(2))
  8 件のコメント
Tamara Szecsey
Tamara Szecsey 2021 年 3 月 25 日
How do I do this without deleting h(2) and instead adding a y-axis to the h(2) too? I tried to change the position command but it doesn't work at all.
Adam Danz
Adam Danz 2021 年 3 月 25 日
編集済み: Adam Danz 2021 年 3 月 25 日
  1. remove the two lines that change the positions of h(1) and h(3)
  2. remove the deletion of h(2)
  3. Look at how Tommy turned on the axes and box for h(3) and repeat that process for h(2)

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

その他の回答 (0 件)

カテゴリ

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

タグ

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by