histogram on data graph

39 visualizaciones (últimos 30 días)
Eli
Eli el 24 de Mzo. de 2024
Editada: Star Strider el 30 de Mzo. de 2024 a las 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?

Respuesta aceptada

Star Strider
Star Strider el 24 de Mzo. de 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 comentarios
Eli
Eli el 30 de Mzo. de 2024 a las 0:51
Editada: Eli el 30 de Mzo. de 2024 a las 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 el 30 de Mzo. de 2024 a las 2:15
Editada: Star Strider el 30 de Mzo. de 2024 a las 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!
.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Holidays / Seasons en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by