How can I name/ categorize columns in my legend?

1 view (last 30 days)
I am plotting temperature against time in two conditions (wind and no wind). In total I have 3 different thermometers, therefore the plot will contain three lines for the no wind condition, and 3 lines for the wind condtion. I want to customize my legend so that it appears like this:
No wind: (line) TCosinuss, (line) Tty, (line)TFastFocus (line)
Wind: (line) TCosinuss, (line) Tty, (line)TFastFocus (line)
This is what I have so far:
hlegend = legend([nw_Cosinuss nw_Tympanic nw_Fastfocus w_Cosinuss w_Tympanic w_Fastfocus], 'T_C_o_s_i_n_u_s_s No Wind', 'T_t_y No Wind', 'T_F_a_s_t_F_o_c_u_s No Wind', 'T_C_o_s_i_n_u_s_s Wind', 'T_t_y Wind', 'T_F_a_s_t_F_o_c_u_s Wind', 'Location', 'SouthOutside', 'Orientation', 'Horizontal', 'FontSize', 15);
hlegend.NumColumns = 3

Answers (1)

Keerthana Chiruvolu
Keerthana Chiruvolu on 10 Mar 2021
Hi Veerle,
Please try using the Categorial Arrays as your variables. For more information, see this.

Tags

Community Treasure Hunt

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

Start Hunting!