Incorrect marker size in legend in errorbar figures

3 views (last 30 days)
I just installed the R2017b version to upgrade from R2016a. Now when I put a legend in an errorbar figure, the marker size in the legend is not the same as the marker size in the plot.
x = 0:0.25:5;
y = x.^2 + 3*x + 2;
rng(1)
y = y + 0.5*randn(1,length(y));
err = 0.5*ones(size(y));
figure
errorbar(x, y, err, 'k.', 'MarkerSize', 20)
legend('errorbar')
This does not happen for the 'plot' function. For example, the code below gives the correct marker size.
figure
plot(x, y, 'k.', 'MarkerSize', 20)
legend('plot')
Using the legacy version of the 'legend' function (as below) solves this issue, but also gets rid of the errorbars in the legend, which I would like to keep if possible.
figure
errorbar(x, y, err, 'k.', 'MarkerSize', 20)
[lgd, icons, plots, txt] = legend('errorbar');
Is there a way to keep the errorbars displayed, as in the new implementation of 'legend', but also have the correct marker size?
Thanks.
  2 Comments
William Davis
William Davis on 30 Nov 2019
Was this problem ever resolved? I have the same issue.
Adam Danz
Adam Danz on 30 Nov 2019
As of r2019b, the marker size in the legend does not necessarily match the marker size in the plot. Note that this is also true with the plot() function. Here's an example of the marker size differing between plot and legend.
clf()
plot(1:5, 1:5, 'k.', 'MarkerSize', 60)
legend('plot')
191129 234625-Figure 2.png

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!