Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

Why will the legend command not display descripitions properly when using a non-solid line style in R2014B?

1 vue (au cours des 30 derniers jours)
KtotheC
KtotheC le 3 Fév 2015
Clôturé : MATLAB Answer Bot le 20 Août 2021
I'm using the legend command in R2014B, and am having issues with it displaying text when a line style other than solid is being used. The code runs successfully in R2012B and works as intended. Try running the example below, thoughts?
figure; hold on; plot([1:10], 1*[1:10], 'b', 'LineWidth', 1); plot([1:10], 2*[1:10], 'r', 'LineWidth', 1); plot([1:10], 3*[1:10], 'g', 'LineWidth', 1, 'LineStyle', '--'); plot([1:10], 4*[1:10], 'm', 'LineWidth', 1, 'LineStyle', '--'); title('Legend Example'); legend({'One','Two','Three','Four'}, 'Location', 'Northwest');
If the "'LineStyle', '--'" options are removed from the above code, the legend appears fine, and the 'Four' label appears.

Réponses (1)

Youssef  Khmou
Youssef Khmou le 3 Fév 2015
Remove the curly brackets and try again as :
h=legend('One','Two','Three','Four', 'Location', 'Northwest');

Cette question est clôturée.

Community Treasure Hunt

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

Start Hunting!

Translated by