Hi, I am trying to plot 12 different markers for a long series of monthly reocord and wish to display the legend using 'text' command so I don't have a separate line of legend for each month. Instead the marker used for a month stays constant across all years. However, am not able to display a 'square' in text command despite using marker 's' in the plot and similarly for other markers. Please help. I tried using interpreter as latex and a '$' sign but got nothing. Here is a sample reproducible ex. I tried on Matlab 2015a.
Thanks in advance.
% sample code starts
temp=rand(14);color_vector=zeros(14,3);color_vector(13,:)=[1 0 0];color_vector(14,:)=[1 0 0];MarkerSet='so^d*+hvp><xso' % repeats after 12th entry
Present_year=2018x_1=1.1;x_2=1.5;x_3=1.8;y_top=2;next_row_rel_loc=0.2;font_val=10;hold onfor ii = 1 : 3 plot(temp(ii,1:3),'marker',MarkerSet(ii),'markersize',10,'markeredgecolor',color_vector(ii,:),'LineStyle','none','linewidth',1) end %ii
ylim([-2 2])text(x_1,y_top, 'Month','FontSize',font_val) %Curr Year Prev Year')
text(x_2,y_top, num2str(Present_year),'FontSize',font_val) text(x_3, y_top, 'Prev. Yr','FontSize',font_val)text(x_1,y_top-next_row_rel_loc, 'Jan','FontSize',font_val)text(x_2, y_top-next_row_rel_loc, '\color{red} s','FontSize',font_val)text(x_3, y_top-next_row_rel_loc, '\color{black} s','FontSize',font_val)text(x_1,y_top-next_row_rel_loc*2, 'Feb','FontSize',font_val)text(x_2, y_top-next_row_rel_loc*2, '\color{red} o','FontSize',font_val)text(x_3, y_top-next_row_rel_loc*2, '\color{black} o','FontSize',font_val)%,'interpreter', 'latex'
%end of sample code
Best Answer