<p><span style="font-family:Arial;font-size:12pt;">[UPDATE]</span><br><br>I made some progress using gsnPanelSave adapting replace_tickmark_labels and calling it after gsn_panel. To make the individual plots of the size I want, I'm drawing some "invisible" labels using res@tmXBLabelFontColor = "Background", then I'm redrawing them as red or blue. As you can see, the result is not great. </p><p> </p><p>If I set res@tmXBLabelFontColor = "Transparent" the script doesn't work. Is there a way to draw transparent labels?  Or is there another way to do what I'm trying to do (see email below)?<br><br>Cheers,</p><p>Giorgio</p><p> </p><p>;----------------------------------------------------------------------<br>; This procedure draw X/Y tickmark labels with custom<br>; labels created by drawing individual text strings read via gsnPanelSave<br>; (adapted from https://www.ncl.ucar.edu/Applications/Scripts/tm_12.ncl<br>; and https://www.ncl.ucar.edu/Applications/Scripts/panel_GWLs_Rain.ncl)<br>;----------------------------------------------------------------------<br>procedure replace_tickmark_labels_panel(wks,plot)<br>local txres, xlabels, ylabels, xmin, ymin, xfonth, yfonth, xangle, xjust<br>begin<br>;---Retrieve some values so we can reconstruct the labels<br> getvalues plot<br>   "tmXBLabels"              : xlabels<br>   "tmYLLabels"              : ylabels<br>   "tmXBValues"              : xvalues<br>   "tmYLValues"              : yvalues<br>   "trXMinF"                 : xmin<br>   "trYMinF"                 : ymin<br>   "tmYLMajorOutwardLengthF" : ylength<br>   "tmXBMajorOutwardLengthF" : xlength<br>   "tmXBLabelFontHeightF"    : xfont_height<br>   "tmYLLabelFontHeightF"    : yfont_height<br>   "tmXBLabelAngleF"         : xangle<br>   "tmXBLabelJust"           : xjust<br> end getvalues</p><p>;---Get the NDC locations for the new tickmark labels<br> xvalues_ndc = new(dimsizes(xvalues),float)<br> yvalues_ndc = new(dimsizes(yvalues),float)<br> xmin_ndc    = new(1,float)<br> ymin_ndc    = new(1,float)<br> datatondc(plot,xvalues,yvalues,xvalues_ndc,yvalues_ndc)<br> datatondc(plot,xmin,ymin,xmin_ndc,ymin_ndc)</p><p>;---Make sure the plot doesn't overlay with the tickmark labels.<br> xmin_ndc = xmin_ndc-0.0075<br> ymin_ndc = ymin_ndc-0.0075<br> <br>;---Color the first four labels red<br> txres = True<br> txres@txJust = xjust<br> txres@txFontColor = "Red"</p><p>;---Draw the first four labels<br> txres@txFontHeightF         = xfont_height<br> gsn_text_ndc(wks,ylabels(0:3),xmin_ndc,yvalues_ndc(0:3),txres)<br> txres@txAngleF = xangle<br> txres@txFontHeightF         = yfont_height<br> gsn_text_ndc(wks,xlabels(0:3),xvalues_ndc(0:3),ymin_ndc,txres)</p><p>;---Color the last four labels blue<br> txres@txFontColor = "Blue"</p><p>;---Draw the last four labels<br> txres@txAngleF = 0.<br> txres@txFontHeightF         = xfont_height<br> gsn_text_ndc(wks,ylabels(4:7),xmin_ndc,yvalues_ndc(4:7),txres)<br> txres@txAngleF = xangle<br> txres@txFontHeightF         = yfont_height<br> gsn_text_ndc(wks,xlabels(4:7),xvalues_ndc(4:7),ymin_ndc,txres)<br>end<br> </p><p> </p><blockquote><p>------ Messaggio Originale ------<br>Da: ncl-talk@mailman.ucar.edu<br>A: ncl-talk@ucar.edu<br>Inviato: venerdì 14 aprile 2023 17:10<br>Oggetto: [ncl-talk] How to use plot tickmark labels with different colors<br> </p><p><span style="font-family:Arial;font-size:12.0pt;">Hello NCLers,</span></p><p> </p><p><span style="font-family:Arial;font-size:12.0pt;">I need to draw tickmark labels with two different colors (red and blue). The script is quite complex; it uses part of https://www.ncl.ucar.edu/Applications/Scripts/table_8.ncl to draw many table plots, which become part of a panel plot (see attached HadCM3_plot_maps_cor_3.png). I can't find a resource like tmXBLabelFontColors, or something able to handle an array of colors like xyLineColors does for lines. Does anyone know if such resource exist?</span></p><p> </p><p><span style="font-family:Arial;font-size:12.0pt;">I tried to generate colored labels in another way. I found this example (https://www.ncl.ucar.edu/Applications/Scripts/tm_12.ncl), containing a procedure able to remove labels from a plot and redraw them. My version of the procedure is pasted below; it reads the value and the location of the labels from the plot function, and draws them again using gsn_text_ndc. I included the procedure in my script but the result is not the intended one (see attached HadCM3_plot_maps_cor_3colored.png).</span></p><p> </p><p><span style="font-family:Arial;font-size:12.0pt;">I found out that there is an unadvertised gsnPanelSave resource used in https://www.ncl.ucar.edu/Applications/Scripts/panel_GWLs_Rain.ncl to to keep the plots in their resized state. I think it might help. Can anyone please tell me how it works?</span></p><p> </p><p><span style="font-family:Arial;font-size:12.0pt;">Cheers,</span></p><p><span style="font-family:Arial;font-size:12.0pt;">Giorgio</span></p><p> </p><p><span style="font-family:Arial;font-size:12.0pt;">;----------------------------------------------------------------------</span><br><span style="font-family:Arial;font-size:12.0pt;">; This procedure replaces a plot's X/Y tickmark labels with custom</span><br><span style="font-family:Arial;font-size:12.0pt;">; labels created by drawing individual text strings </span><br><span style="font-family:Arial;font-size:12.0pt;">; (adapted from https://www.ncl.ucar.edu/Applications/Scripts/tm_12.ncl)</span><br><span style="font-family:Arial;font-size:12.0pt;">;----------------------------------------------------------------------</span><br><span style="font-family:Arial;font-size:12.0pt;">procedure replace_tickmark_labels(wks,plot)</span><br><span style="font-family:Arial;font-size:12.0pt;">local txres, xlabels, ylabels, xmin, ymin, xfonth, yfonth</span><br><span style="font-family:Arial;font-size:12.0pt;">begin</span><br><span style="font-family:Arial;font-size:12.0pt;">;---Turn off plot's X and Y tickmark labels</span><br><span style="font-family:Arial;font-size:12.0pt;"> setvalues plot</span><br><span style="font-family:Arial;font-size:12.0pt;">   "tmXBLabelsOn"  : False</span><br><span style="font-family:Arial;font-size:12.0pt;">   "tmYLLabelsOn"  : False</span><br><span style="font-family:Arial;font-size:12.0pt;"> end setvalues</span><br><span style="font-family:Arial;font-size:12.0pt;">   </span><br><span style="font-family:Arial;font-size:12.0pt;">;---Retrieve some values so we can reconstruct the labels</span><br><span style="font-family:Arial;font-size:12.0pt;"> getvalues plot</span><br><span style="font-family:Arial;font-size:12.0pt;">   "tmXBLabels"              : xlabels</span><br><span style="font-family:Arial;font-size:12.0pt;">   "tmYLLabels"              : ylabels</span><br><span style="font-family:Arial;font-size:12.0pt;">   "tmXBValues"              : xvalues</span><br><span style="font-family:Arial;font-size:12.0pt;">   "tmYLValues"              : yvalues</span><br><span style="font-family:Arial;font-size:12.0pt;">   "trXMinF"                 : xmin</span><br><span style="font-family:Arial;font-size:12.0pt;">   "trYMinF"                 : ymin</span><br><span style="font-family:Arial;font-size:12.0pt;">   "tmYLMajorOutwardLengthF" : ylength</span><br><span style="font-family:Arial;font-size:12.0pt;">   "tmXBMajorOutwardLengthF" : xlength</span><br><span style="font-family:Arial;font-size:12.0pt;">   "tmXBLabelFontHeightF"    : xfont_height</span><br><span style="font-family:Arial;font-size:12.0pt;">   "tmYLLabelFontHeightF"    : yfont_height</span><br><span style="font-family:Arial;font-size:12.0pt;"> end getvalues</span></p><p><span style="font-family:Arial;font-size:12.0pt;">;---Get the NDC locations for the new tickmark labels</span><br><span style="font-family:Arial;font-size:12.0pt;"> xvalues_ndc = new(dimsizes(xvalues),float)</span><br><span style="font-family:Arial;font-size:12.0pt;"> yvalues_ndc = new(dimsizes(yvalues),float)</span><br><span style="font-family:Arial;font-size:12.0pt;"> xmin_ndc    = new(1,float)</span><br><span style="font-family:Arial;font-size:12.0pt;"> ymin_ndc    = new(1,float)</span><br><span style="font-family:Arial;font-size:12.0pt;"> datatondc(plot,xvalues,yvalues,xvalues_ndc,yvalues_ndc)</span><br><span style="font-family:Arial;font-size:12.0pt;"> datatondc(plot,xmin,ymin,xmin_ndc,ymin_ndc)</span></p><p><span style="font-family:Arial;font-size:12.0pt;">;---Make sure the tickmark labels don't touch the tickmarks.</span><br><span style="font-family:Arial;font-size:12.0pt;"> xmin_ndc = xmin_ndc-(1.8*ylength)     </span><br><span style="font-family:Arial;font-size:12.0pt;"> ymin_ndc = ymin_ndc-(1.8*xlength)</span><br><span style="font-family:Arial;font-size:12.0pt;"> </span><br><span style="font-family:Arial;font-size:12.0pt;">;---Color the first four labels red</span><br><span style="font-family:Arial;font-size:12.0pt;"> txres = True</span><br><span style="font-family:Arial;font-size:12.0pt;"> txres@txFontColor = "Red"</span></p><p><span style="font-family:Arial;font-size:12.0pt;">;---Draw the first four labels</span><br><span style="font-family:Arial;font-size:12.0pt;"> txres@txFontHeightF         = xfont_height</span><br><span style="font-family:Arial;font-size:12.0pt;"> gsn_text_ndc(wks,ylabels(0:3),xmin_ndc,yvalues_ndc(0:3),txres)</span><br><span style="font-family:Arial;font-size:12.0pt;"> txres@txFontHeightF         = yfont_height</span><br><span style="font-family:Arial;font-size:12.0pt;"> gsn_text_ndc(wks,xlabels(0:3),xvalues_ndc(0:3),ymin_ndc,txres)</span></p><p><span style="font-family:Arial;font-size:12.0pt;">;---Color the last four labels blue</span><br><span style="font-family:Arial;font-size:12.0pt;"> txres@txFontColor = "Blue"</span></p><p><span style="font-family:Arial;font-size:12.0pt;">;---Draw the last four labels</span><br><span style="font-family:Arial;font-size:12.0pt;"> txres@txFontHeightF         = xfont_height</span><br><span style="font-family:Arial;font-size:12.0pt;"> gsn_text_ndc(wks,ylabels(4:7),xmin_ndc,yvalues_ndc(4:7),txres)</span><br><span style="font-family:Arial;font-size:12.0pt;"> txres@txFontHeightF         = yfont_height</span><br><span style="font-family:Arial;font-size:12.0pt;"> gsn_text_ndc(wks,xlabels(4:7),xvalues_ndc(4:7),ymin_ndc,txres)</span></p><p><span style="font-family:Arial;font-size:12.0pt;">end</span><br> </p><hr><p>_______________________________________________<br>ncl-talk mailing list<br><span class="wt_Email">ncl-talk@mailman.ucar.edu</span><br>List instructions, subscriber options, unsubscribe:<br><a target="_blank" rel="noopener noreferrer" href="https://mailman.ucar.edu/mailman/listinfo/ncl-talk">https://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br> </p></blockquote>