histogram on data graph

4 ビュー (過去 30 日間)
Eli
Eli 2024 年 3 月 24 日
編集済み: Star Strider 2024 年 3 月 30 日
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 日
編集済み: Eli 2024 年 3 月 30 日
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 日
編集済み: Star Strider 2024 年 3 月 30 日
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 Center および File ExchangeData Distribution Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by