histogram on data graph

24 visualizzazioni (ultimi 30 giorni)
Eli
Eli il 24 Mar 2024
Modificato: Star Strider il 30 Mar 2024 alle 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?

Risposta accettata

Star Strider
Star Strider il 24 Mar 2024
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 Commenti
Eli
Eli il 30 Mar 2024 alle 0:51
Modificato: Eli il 30 Mar 2024 alle 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 il 30 Mar 2024 alle 2:15
Modificato: Star Strider il 30 Mar 2024 alle 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!
.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Holidays / Seasons in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by