How to skip legend entries to align the right colors?

7 visualizzazioni (ultimi 30 giorni)
I am using column plot as developed by: https://au.mathworks.com/matlabcentral/fileexchange/27389-simonhenin-columnlegend . I am using plot in a for loop as shown following:
I only want to change the plot color when n changes however the column legend is creating additional objects that I don't need in the legend and therefore displays items that does not match with the allocated colors.
The question I have is how do I get skip legend entries and make the colors match appropriately. There should be one color corresponding to each location.
Thanks any useful responses.

Risposta accettata

Ted Yang
Ted Yang il 28 Set 2018
Modificato: Ted Yang il 28 Set 2018
I managed solve this question myself, all you have to do is modify the columnlegend to include a handle specifying the corresponding plots you wanted to include in the legend. This means modifying the column legend code to have an extra argument - handle of the plot h1 = plot(...). where h(i) vector stores all the h1 handle of the plots that you wanted to include in the legend section. Columnlegend(h,numofcolumns,...) and modify the create legend function (h) inside the function.
So pass h = [h1 h1 h1 h1 ....] into Columnlegend.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by