Plotting confidence intervals with only one serie in the legend
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello,
In a figure, I plotted a series of data. After having calculated the average, lower and upper limits of both 95% and 99.4% confidence intervals, I added them to the figure. Then, I inserted the legend. Here, all the 6 series' labels appear. What I would then like is to remove from the legend labels, one of the 2 labels corresponding to 95% confidence intervals and one of the 2 labels of the 99.4%. But, Matlab doesn't allow me to do it. Could you help e to solve this problem ? Thanks and best regards.
0 comentarios
Respuesta aceptada
the cyclist
el 8 de Jun. de 2012
There are several different approaches to doing this, but you didn't share your code, so it is not possible to know which method fits best with how your code currently operates. However, the key is to only supply the legend() command with the handles for the objects you want to appear in the legend. Here's a simple example that illustrates the approach. I hope you can figure out how to work the same approach into your code:
figure
hold on
h1 = plot(1:100,rand(1,100)+1,'g-');
h2 = plot(1:100,rand(1,100), 'b-');
h3 = plot(1:100,rand(1,100)-1,'r-');
legend([h1 h2],{'top','middle'}); % I did not include the handle for the bottom line
2 comentarios
Tom Lane
el 12 de Jun. de 2012
Instead of inserting the legend from the figure toolbar, try getting handles from the plot commands as the cyclist suggests, and supplying labels for the handles that you want to include in the legend.
Más respuestas (0)
Ver también
Categorías
Más información sobre Legend en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!