How to skip legend entries to align the right colors?

조회 수: 7 (최근 30일)
Ted Yang
Ted Yang 2018년 9월 28일
편집: Ted Yang 2018년 9월 28일
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.

채택된 답변

Ted Yang
Ted Yang 2018년 9월 28일
편집: Ted Yang 2018년 9월 28일
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.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Legend에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by