Thanks for the help. That's what I'm trying do, although this is kind of a brute force way of doing it. I was sort of hoping that there would be a way to set the color map directly to the histogram. I guess I'll need to make a function for this.
Using a colormap to match a contour to a histogram
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Pete Marsh
el 3 de Oct. de 2019
Respondida: Pete Marsh
el 3 de Oct. de 2019
I am regenerating cscan TOF data ( contourf(xscale, yscale, cscan, 40,'linestyle','--') ) and I would am trying to display a histogram of the data such that the bar colors will be the same a shown in the histogram (say red in the contour = 400 ns would have the histogram bar at 400 also be red). Is there an easy way to assign the bars using the colormap?
0 comentarios
Respuesta aceptada
Más respuestas (1)
Jess Lovering
el 3 de Oct. de 2019
Editada: Jess Lovering
el 3 de Oct. de 2019
Here is an example of what I think you are trying to do. It doesn't calculate the bar values for the contours - I assume you have an associated value for each contour already available. Please let me know if this example is what you are looking for.
figure
subplot(2,1,1)
Z = peaks;
[M c]=contour(Z);
cmap = colormap;
crange = caxis;
cmin = crange(1);
cmax = crange(2);
m = length(cmap);
subplot(2,1,2)
hold on
contour_levels = -6:8;
bar_vals = rand(1,length(contour_levels)); % I assume you have these calculated
for ii = 1:length(contour_levels)
contour_i = contour_levels(ii);
cp = (contour_i-cmin)/(cmax-cmin);
ci = round((length(cmap)-1)*cp)+1;
color(ii,1:3) = cmap(ci,:);
bh = bar(contour_levels(ii),bar_vals(ii))
bh.FaceColor = cmap(ci,:);
end
0 comentarios
Ver también
Categorías
Más información sobre Data Distribution Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!