Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The legend is not aligned on the y-axis, when ncol is not equal to 0 #16

Open
mengyingzhou opened this issue Apr 20, 2020 · 1 comment
Labels

Comments

@mengyingzhou
Copy link

mengyingzhou commented Apr 20, 2020

hi
Thanks for your wonderful work.
I find a slight mistake when I apply the legendflex in bar function. When ncol is set to 3, the legend is not aligned on the y-axis. The second legend is slightly lower than the first legend.
This is my code:

figure(1);clf;
h = bar(rand(10,3));
hatchfill2(h(1),'single','HatchAngle',0,'HatchDensity',30,'HatchColor','w','HatchLineWidth',1.5);
hatchfill2(h(2),'single','HatchAngle',135,'HatchDensity',30,'HatchColor','w','HatchLineWidth',1.5);
hatchfill2(h(3),'single','HatchAngle',45,'HatchDensity',30,'HatchColor','w','HatchLineWidth',1.5);
[~,legend_h,~,~] = legendflex(h,{'e1','e2','e3'},'anchor', [2 6],'buffer', [ 0  10], 'FontSize', 20, 'ncol', 3, 'box', 'on');

Then, I checked the YData of the legend and found that they are not consistent with each other in the forth and fifth elements:

>> legend_h(length(h)+1).Children(1).YData

ans =

    9.2889
   34.3889
   34.3889
    9.2889
    9.2889

>> legend_h(length(h)+2).Children(1).YData

ans =

    7.3694
   32.4694
   32.4694
    7.3694
    7.3694

thx!

mengying

@kakearney
Copy link
Owner

Thank you for noting this. It appears to be related to the font size modification; I'll have to determine whether the mistake is in my code or in the underlying call to legend.

@kakearney kakearney added the bug label Aug 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants