I am in the process of redoing a figure for a publication that needs to be changed up a bit based on reviewer comments. I have to create a plot legend that covers four different subplots and needs to include elements not included in all four subplots that all have two y-axes. To create the legend, I created an extra row of subplots and merged them to make a dummy subplot. I plotted generic versions of all the plot elements that need to be included in the legend, created the legend, and then hid the plot elements and the subplot itself so that the only thing still visible is the legend which is then dragged into the desired position. All went to plan except for the fact that the the symbols/lines/text in the legend appear to be several shades lighter than they should be. Briefly troubleshooting, I noticed hiding everything is what results in the lighter shades. The first version of the code I wrote to create the figure involved creating two different figures instead of the "two different subplots" and then I just cut and paste the legend into the figure separately outside of MATLAB. It would ideal just to get the plot and legend generated properly by the same code. Code below and figure attached. The code is very long, but the last 21 lines of code are of most interest for this question. Thank you in advance for any and all help.
set(0,'defaultfigurecolor','w');figure(1)colormap jeth1 = subplot(5,5,[1,2,6,7]);yyaxis leftarea(hour1,sal1,'FaceColor',[0.8300 0.8300 0.8300],'EdgeColor',[0.8300 0.8300 0.8300],'LineStyle','-');ylim([5.6 26.4]);set(gca,'FontSize',10);set(gca,'ycolor','k');set(gca,'ytick',[8 12 16 20 24]);ytix = get(gca,'ytick');ytixlbl = regexp(sprintf('%.0f\n',ytix), '\n', 'split');set(gca,'yticklabel',ytixlbl(1:end-1));ylabel('Salinity','FontSize',10,'FontWeight','bold');text(7.0,26.6,'a','FontSize',18,'FontWeight','bold');str1 = {'01 June 2016'};text(14.8,25,str1,'FontSize',10,'FontWeight','bold');yyaxis rightscatter(hour1,ph1,50,'o','filled','MarkerFaceColor',[0 0 0.8]);hold onplot(hour1,ph1,'Color',[0 0 0.8],'LineWidth',1,'LineStyle','-');hold offylim([-10.8 82.8]);set(gca,'FontSize',10);set(gca,'ycolor','k');set(gca,'ytick',[0 18 36 54 72]);ytix = get(gca,'ytick');ytixlbl = regexp(sprintf('%.0f\n',ytix), '\n', 'split');set(gca,'yticklabel',ytixlbl(1:end-1));ylabel('[H^{+}_{T}] (nmol kg^{-1})','FontSize',10,'FontWeight','bold');xlim([8.5 19.5]);set(gca,'xtick',[9,11,13,15,17,19]);xlabel('Hour','FontSize',10,'FontWeight','bold');set(gca,'FontSize',10);box onh2 = subplot(5,5,[4,5,9,10]);yyaxis leftarea(hour1,sal1,'FaceColor',[0.8300 0.8300 0.8300],'EdgeColor',[0.8300 0.8300 0.8300],'LineStyle','-');ylim([5.6 26.4]);set(gca,'FontSize',10);set(gca,'ycolor','k');set(gca,'ytick',[8 12 16 20 24]);ytix = get(gca,'ytick');ytixlbl = regexp(sprintf('%.0f\n',ytix), '\n', 'split');set(gca,'yticklabel',ytixlbl(1:end-1));ylabel('Salinity','FontSize',10,'FontWeight','bold');text(7.0,26.6,'b','FontSize',18,'FontWeight','bold');str1 = {'01 June 2016'};text(14.8,25,str1,'FontSize',10,'FontWeight','bold');yyaxis rightscatter(hour1,dic1,75,'s','filled','MarkerFaceColor',[0.5500 0.7100 0.0000]);hold onscatter(hour1,ta1,60,'>','filled','MarkerFaceColor',[0.9100 0.4100 0.1700]);hold onplot(hour1,dic1,'Color',[0.5500 0.7100 0.0000],'LineWidth',1,'LineStyle','-');hold onplot(hour1,ta1,'Color',[0.9100 0.4100 0.1700],'LineWidth',1,'LineStyle','-');hold offylim([1440 1960]);set(gca,'FontSize',10);set(gca,'ycolor','k');set(gca,'ytick',[1500 1600 1700 1800 1900]);ytix = get(gca,'ytick');ytixlbl = regexp(sprintf('%.0f\n',ytix), '\n', 'split');set(gca,'yticklabel',ytixlbl(1:end-1));ylabel('DIC or TA (\mumol kg^{-1})','FontSize',10,'FontWeight','bold');xlim([8.5 19.5]);set(gca,'xtick',[9,11,13,15,17,19]);xlabel('Hour','FontSize',10,'FontWeight','bold');set(gca,'FontSize',10);box onh3 = subplot(5,5,[11,12,16,17]);yyaxis leftarea(hour2,sal2,'FaceColor',[0.8300 0.8300 0.8300],'EdgeColor',[0.8300 0.8300 0.8300],'LineStyle','-');ylim([18.8 29.2]);set(gca,'FontSize',10);set(gca,'ycolor','k');set(gca,'ytick',[20 22 24 26 28]);ytix = get(gca,'ytick');ytixlbl = regexp(sprintf('%.0f\n',ytix), '\n', 'split');set(gca,'yticklabel',ytixlbl(1:end-1));ylabel('Salinity','FontSize',10,'FontWeight','bold');text(6.05,29.3,'c','FontSize',18,'FontWeight','bold');str1 = {'02 August 2016'};text(14.93,28.5,str1,'FontSize',10,'FontWeight','bold');yyaxis rightscatter(hour2,ph2,50,'o','filled','MarkerFaceColor',[0 0 0.8]);hold onplot(hour2,ph2,'Color',[0 0 0.8],'LineWidth',1,'LineStyle','-');hold offylim([-2 102]); set(gca,'FontSize',10);set(gca,'ycolor','k');set(gca,'ytick',[10 30 50 70 90]);ytix = get(gca,'ytick');ytixlbl = regexp(sprintf('%.0f\n',ytix), '\n', 'split');set(gca,'yticklabel',ytixlbl(1:end-1));ylabel('[H^{+}_{T}] (nmol kg^{-1})','FontSize',10,'FontWeight','bold');xlim([7.75 20]);set(gca,'xtick',[8 10 12 14 16 18 20]);xlabel('Hour','FontSize',10,'FontWeight','bold');set(gca,'FontSize',10);box onp3 = get(h3,'Position');p3(2) = p3(2)-0.015;set(h3,'pos',p3);h4 = subplot(5,5,[14,15,19,20]);yyaxis leftarea(hour2,sal2,'FaceColor',[0.8300 0.8300 0.8300],'EdgeColor',[0.8300 0.8300 0.8300],'LineStyle','-');ylim([18.8 29.2]);set(gca,'FontSize',10);set(gca,'ycolor','k');set(gca,'ytick',[20 22 24 26 28]);ytix = get(gca,'ytick');ytixlbl = regexp(sprintf('%.0f\n',ytix), '\n', 'split');set(gca,'yticklabel',ytixlbl(1:end-1));ylabel('Salinity','FontSize',10,'FontWeight','bold');text(6.05,29.3,'d','FontSize',18,'FontWeight','bold');str1 = {'02 August 2016'};text(14.93,28.5,str1,'FontSize',10,'FontWeight','bold');yyaxis rightscatter(hour2,dic2,75,'s','filled','MarkerFaceColor',[0.5500 0.7100 0.0000]);hold onscatter(hour2,ta2,60,'>','filled','MarkerFaceColor',[0.9100 0.4100 0.1700]);hold onplot(hour2,dic2,'Color',[0.5500 0.7100 0.0000],'LineWidth',1,'LineStyle','-');hold onplot(hour2,ta2,'Color',[0.9100 0.4100 0.1700],'LineWidth',1,'LineStyle','-');hold offylim([1740 2260]);set(gca,'FontSize',10);set(gca,'ycolor','k');set(gca,'ytick',[1800 1900 2000 2100 2200]);ytix = get(gca,'ytick');ytixlbl = regexp(sprintf('%.0f\n',ytix), '\n', 'split');set(gca,'yticklabel',ytixlbl(1:end-1));ylabel('DIC or TA (\mumol kg^{-1})','FontSize',10,'FontWeight','bold');xlim([7.75 20]);set(gca,'xtick',[8 10 12 14 16 18 20]);xlabel('Hour','FontSize',10,'FontWeight','bold');set(gca,'FontSize',10);box onp4 = get(h4,'Position');p4(2) = p4(2)-0.015;set(h4,'pos',p4);h5 = subplot(5,5,[21,22,23,24,25]); set(0,'defaultfigurecolor','w');colormap jetelement1 = area(hour1,sal1,'FaceColor',[0.8300 0.8300 0.8300],'EdgeColor',[0.8300 0.8300 0.8300],'LineStyle','-');hold onelement2 = plot(hour1,ph1,'-o','MarkerEdgeColor',[0 0 0.8],'LineWidth',1,'MarkerFaceColor',[0 0 0.8],'MarkerSize',7,'Color',[0 0 0.8]);hold onelement3 = plot(hour1,dic1,'-s','MarkerEdgeColor',[0.5500 0.7100 0.000],'LineWidth',1,'MarkerFaceColor',[0.5500 0.7100 0.000],'MarkerSize',10,'Color',[0.5500 0.7100 0.0000]);hold onelement4 = plot(hour1,ta1,'->','MarkerEdgeColor',[0.9100 0.4100 0.1700],'LineWidth',1,'MarkerFaceColor',[0.9100 0.4100 0.1700],'MarkerSize',7,'Color',[0.9100 0.4100 0.1700]);hold offplotleg = legend('Salinity','[H^{+}_{T}]','DIC','TA','Location','bestoutside','Orientation','vertical');legend('boxon');set(plotleg,'FontSize',13);box off axis off set(element1,'Visible','off'); set(element2,'Visible','off'); set(element3,'Visible','off');set(element4,'Visible','off');set(h5,'Visible','off');
Best Answer