histogram on data graph

조회 수: 39 (최근 30일)
Eli
Eli 2024년 3월 24일
편집: Star Strider 2024년 3월 30일 10:32
Hi,
I have a graph i plot as
plot(x,y). it looks like this:
I want to make it a histogram like this:
both the inner colors as you see correspond to the histogram, and also the histogram on the right side of each graph.
How can i do it?

채택된 답변

Star Strider
Star Strider 2024년 3월 24일
One option (if your data were a scatter plot) would be the scatterhist or scatterhistogram functions.
Otherwise, perhaps something like this —
x = linspace(0, 100, 1000);
y = randn(size(x));
pd = fitdist(y(:), 'normal');
xd = linspace(min(y), max(y), 250);
yd = pdf(pd, xd);
figure
tiledlayout(1,3, 'TileSpacing','none')
nexttile([1 2])
plot(x, y)
nexttile
plot(yd,xd)
Ax3 = gca;
Ax3.XTick = [];
Ax3.YTick = [];
Experiment to get the result you want.
.
  댓글 수: 14
Eli
Eli 2024년 3월 30일 0:51
편집: Eli 2024년 3월 30일 10:20
I found a way with it. it's not the best, but still it works.
using:
print('-vector','-depsc','myVectorFile')
And than need to insert EPS file to inkspace accoring to :
it's not the perfect solution, but it's good enough for now.
Star Strider
Star Strider 2024년 3월 30일 2:15
편집: Star Strider 2024년 3월 30일 10:32
O.K.
I don’t have any experience with vector graphics. It’s never been something I needed to understand.
I just knew that the print function can save graphics objects in a variety of formats, so I suggested it.
Another option that I jjust now thought of is the exportgraphics function. (Again, I have no experience with it.)
EDIT — (30 Mar 2024 at 10:32)
I’m glad you found a solution. It’s difficult to help you because you never share your code or data, so I’m left guessing. I won’t from here on. Good luck with your projects!
.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Holidays / Seasons에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by