How to rescale bar3 independent of colorbar?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Thanks for considering my question!
I made these 4 plots using the bar3 function like so:
figure(fig)
plt=subplot(2,2,plt_ndx);
gobj=bar3(data_matrix);
% set the color of each bar
for cndx=1:length(column_flags)
gobj(cndx).CData=cdata_matrix{cndx};
end
colormap('parula')
colorbar
% set the axis labels
yticklabels(cellfun(@(x) num2str(x),num2cell(2:4),'UniformOutput',false))
ylabel('time option')
xcell=cellfun(@(x) num2str(x),num2cell(sort([3:7,3])),'UniformOutput',false);
xcell{2}=[xcell{2},'_oo2'];
xticklabels(xcell)
xlabel('max dimension kept')
title(title_text)
The result is awful.
I expected the color bar and the axis to be the same height. However the color bar is much larger. If I try to rescale the axes by dragging on a corner the color bar grows proportionately. This quickly becomes absurd like so:
Using the property editor is also cumbersome and does not produce the desired effects. I like the height of the colorbars in the original image. I also like that bar3 locks the aspect ratio. However I want the bar3 axese to be the same height as the original colorbar.
Note that if I query the height of the axese and colorbars, it shows that they are already the same height, even though they clearly are not.
>> fig.Children(1)
ans =
ColorBar with properties:
Location: 'eastoutside'
Limits: [-1 1]
FontSize: 9
Position: [0.6731 0.1100 0.0072 0.3412]
Units: 'normalized'
Show all properties
>> fig.Children(2)
ans =
Axes (\alpha=0.2 SVD embedding ensemble of 9 dc 1) with properties:
XLim: [0.6000 3.4000]
YLim: [0 4]
XScale: 'linear'
YScale: 'linear'
GridLineStyle: '-'
Position: [0.5821 0.1100 0.0716 0.3412]
Units: 'normalized'
Show all properties
Perhaps it's maintaining the aspect ratio by adjusting the height to equal the width and then adjusting the width so that the color bar and axis both fit into some kind of arbitrary "bounding box"? Maybe I can tell matlab to fix the height and maintain the aspect ratio by adjusting the width instead. Maybe I can change the bounding box?
Has anyone seen this before? How can I make sure the bar3 axese are the same height as the original colorbar, while keeping the colorbar height also fixed at it's original value?
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Colormaps dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!