<div dir="ltr">Hi Giorgio,<div>You have a lot going on in the code snippet you sent, with numerous calls to gsn_attach_plots and overlay. Yes, it is possible to do what you want, but as you can tell already there is a bit of art to this. I would recommend not setting gsnMaximize for anything (which you are not), and pay particular attention to the vpYF/vpHeightF settings for your various resource lists. The values should be identical across your resa, resb and rez resource lists, otherwise the sizes and locations of the plots will be different. I'd try setting vpYF = 0.8 and vpHeightF = 0.6 to start. Finally, I would not call drawNDCGrids until right before the frame(wks) call as it freezes the size of the frame. That shouldn't affect anything with your script as you are not maximizing, but just to be sure I would move the call. </div><div><br></div><div>Hope the above helps!</div><div>Adam</div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jul 7, 2021 at 5:33 AM Giorgio Graffino via ncl-talk <<a href="mailto:ncl-talk@mailman.ucar.edu" target="_blank">ncl-talk@mailman.ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><p style="font-size:12pt;font-family:Arial">Dear NCL folks,</p><p style="font-size:12pt;font-family:Arial"><br></p><p style="font-size:12pt;font-family:Arial">I'm trying to draw a XY plot by attaching four subplots together and giving each of them its own vertical axis. This last point is particularly tricky. Taking inspiration from this example (<a href="https://www.ncl.ucar.edu/Applications/Scripts/xy_22.ncl" target="_blank">https://www.ncl.ucar.edu/Applications/Scripts/xy_22.ncl</a>), I'm trying now to draw individual vertical axis using gsn_blank_plot, but I can't make all the plots to arrange nicely (see <span style="font-family:arial,sans-serif;font-size:12pt">HadCM3_plot_temp_ohue.000003.png</span><span style="font-size:12pt;font-family:Arial">) even when I </span>explicitly<span style="font-size:12pt;font-family:Arial"> set the NDC coordinates of the main plot (see code snippet below). </span></p><p style="font-size:12pt;font-family:Arial"><span style="font-size:12pt;font-family:Arial"><br></span></p><p style="font-size:12pt;font-family:Arial"><span style="font-size:12pt;font-family:Arial">What I'd like to have is something like </span><span style="font-family:arial,sans-serif;font-size:12pt">HadCM3_plot_temp_ohue.000004.png, but with individual axes for each subplot. </span><span style="font-family:arial,sans-serif;font-size:12pt">Can it be done? Is there an easier way to get a nice result?</span></p><p style="font-size:12pt;font-family:Arial"><span style="font-family:arial,sans-serif;font-size:12pt"><br></span></p><p style="font-size:12pt;font-family:Arial"><span style="font-family:arial,sans-serif;font-size:12pt">Cheers,</span></p><p style="font-size:12pt;font-family:Arial"><span style="font-family:arial,sans-serif;font-size:12pt">Giorgio</span></p><p style="font-size:12pt;font-family:Arial"><span style="font-family:arial,sans-serif;font-size:12pt"><br></span></p><p><span style="font-family:Arial;font-size:12pt">deltapl = fspan(0.2,0.8,5)</span></p><p><span style="font-family:Arial;font-size:12pt">; resa@gsnMaximize = True </span></p><p><span style="font-family:Arial;font-size:12pt"> resa@gsnDraw = False ; Don't draw plot</span></p><p><span style="font-family:Arial;font-size:12pt"> resa@gsnFrame = False ; Don't advance frame</span></p><p><span style="font-family:Arial;font-size:12pt"> resa@gsnYRefLine = 0.</span></p><p><span style="font-family:Arial;font-size:12pt"> resa@tiMainString = ""</span></p><p><span style="font-family:Arial;font-size:12pt"> resa@tiMainFontHeightF = 0.015</span></p><p><span style="font-family:Arial;font-size:12pt"> resa@tiXAxisString = ""</span></p><p><span style="font-family:Arial;font-size:12pt"> resa@tiYAxisString = ""</span></p><p><span style="font-family:Arial;font-size:12pt"> resa@tiYAxisFontHeightF = 0.0125</span></p><p><span style="font-family:Arial;font-size:12pt"> resa@tmXBMode = "Explicit"</span></p><p><span style="font-family:Arial;font-size:12pt"> resa@tmXBLabelAngleF = 45.</span></p><p><span style="font-family:Arial;font-size:12pt"> resa@tmXBLabelFontHeightF = 0.0125</span></p><p><span style="font-family:Arial;font-size:12pt"> resa@tmXBLabelJust = "TopRight"</span></p><p><span style="font-family:Arial;font-size:12pt"> resa@tmXBLabels := (/"Pos","Neg"/)</span></p><p><span style="font-family:Arial;font-size:12pt"> resa@tmXBValues := (/0.8,1.2/)</span></p><p><span style="font-family:Arial;font-size:12pt"> resa@tmXUseBottom = False</span></p><p><span style="font-family:Arial;font-size:12pt"> resa@tmXTLabelsOn = True</span></p><p><span style="font-family:Arial;font-size:12pt"> resa@tmXTMode = "Explicit"</span></p><p><span style="font-family:Arial;font-size:12pt"> resa@tmXTLabelAngleF = 45.</span></p><p><span style="font-family:Arial;font-size:12pt"> resa@tmXTLabelFontHeightF = 0.0125</span></p><p><span style="font-family:Arial;font-size:12pt"> resa@tmXTLabelJust = "BottomLeft"</span></p><p><span style="font-family:Arial;font-size:12pt"> resa@tmXTLabels = labels1(0)</span></p><p><span style="font-family:Arial;font-size:12pt"> resa@tmXTValues = 1.</span></p><p><span style="font-family:Arial;font-size:12pt"> resa@tmYLLabelFontHeightF = 0.0125</span></p><p><span style="font-family:Arial;font-size:12pt"> resa@trXMinF = 0.5</span></p><p><span style="font-family:Arial;font-size:12pt"> resa@trXMaxF = 1.5</span></p><p><span style="font-family:Arial;font-size:12pt"> resa@trYMinF = 0.</span></p><p><span style="font-family:Arial;font-size:12pt"> resa@trYMaxF = 0.5</span></p><p><span style="font-family:Arial;font-size:12pt"> resa@vpHeightF = 0.8</span></p><p><span style="font-family:Arial;font-size:12pt"> resa@vpWidthF = 0.15</span></p><p><span style="font-family:Arial;font-size:12pt"> resa@vpXF = 0.2</span></p><p><span style="font-family:Arial;font-size:12pt"> resa@vpYF = 0.8</span></p><p><span style="font-family:Arial;font-size:12pt"> resa@xyMarkLineMode = "Markers" ; choose to use markers</span></p><p><span style="font-family:Arial;font-size:12pt"> resa@xyMarkers := markrs</span></p><p><span style="font-family:Arial;font-size:12pt"> resa@xyMarkerColors := (/"Black","Red","Pink","Grey"/)</span></p><p><span style="font-family:Arial;font-size:12pt"> resa@xyMarkerSizeF = 0.015 ; Marker size (default 0.01)</span></p><p><span style="font-family:Arial;font-size:12pt"> resa@xyMarkerThicknessF = 3.</span></p><p><span style="font-family:Arial;font-size:12pt">; resb@gsnMaximize = True </span></p><p><span style="font-family:Arial;font-size:12pt"> resb@gsnDraw = False ; Don't draw plot</span></p><p><span style="font-family:Arial;font-size:12pt"> resb@gsnFrame = False ; Don't advance frame</span></p><p><span style="font-family:Arial;font-size:12pt"> resb@tiMainFontHeightF = 0.015</span></p><p><span style="font-family:Arial;font-size:12pt"> resb@trXMinF = 0.5</span></p><p><span style="font-family:Arial;font-size:12pt"> resb@trXMaxF = 1.5</span></p><p><span style="font-family:Arial;font-size:12pt"> resb@trYMinF = 0.</span></p><p><span style="font-family:Arial;font-size:12pt"> resb@trYMaxF = 0.5</span></p><p><span style="font-family:Arial;font-size:12pt"> resb@xyMarkLineMode = "Markers" ; choose to use markers</span></p><p><span style="font-family:Arial;font-size:12pt"> resb@xyMarkers := markrs</span></p><p><span style="font-family:Arial;font-size:12pt"> resb@xyMarkerColors := (/"Purple","Blue","Cyan","Green"/)</span></p><p><span style="font-family:Arial;font-size:12pt"> resb@xyMarkerSizeF = 0.015 ; Marker size (default 0.01)</span></p><p><span style="font-family:Arial;font-size:12pt"> resb@xyMarkerThicknessF = 3.</span></p><p><span style="font-family:Arial;font-size:12pt"> resb@vpHeightF = 0.8</span></p><p><span style="font-family:Arial;font-size:12pt"> resb@vpWidthF = 0.15</span></p><p><span style="font-family:Arial;font-size:12pt"> resb@vpXF = 0.2</span></p><p><span style="font-family:Arial;font-size:12pt"> resb@vpYF = 0.8</span></p><p><span style="font-family:Arial;font-size:12pt"> resz@gsnDraw = False</span></p><p><span style="font-family:Arial;font-size:12pt"> resz@gsnFrame = False</span></p><p><span style="font-family:Arial;font-size:12pt"> resz@tmXBOn = False ; Turn off X axis since it has already</span></p><p><span style="font-family:Arial;font-size:12pt"> resz@tmXBBorderOn = False ; been drawn.</span></p><p><span style="font-family:Arial;font-size:12pt"> resz@tmXBLabelsOn = False</span></p><p><span style="font-family:Arial;font-size:12pt"> resz@tmXTOn = False</span></p><p><span style="font-family:Arial;font-size:12pt"> resz@tmXTBorderOn = False</span></p><p><span style="font-family:Arial;font-size:12pt"> resz@tmXTLabelsOn = False</span></p><p><span style="font-family:Arial;font-size:12pt"> resz@tmYLOn = True ; Turn on left Y axis.</span></p><p><span style="font-family:Arial;font-size:12pt"> resz@tmYLBorderOn = True</span></p><p><span style="font-family:Arial;font-size:12pt"> resz@tmYLLabelsOn = True</span></p><p><span style="font-family:Arial;font-size:12pt"> resz@tmYLLabelFontHeightF = 0.0125</span></p><p><span style="font-family:Arial;font-size:12pt"> resz@tmYROn = False</span></p><p><span style="font-family:Arial;font-size:12pt"> resz@tmYRBorderOn = False</span></p><p><span style="font-family:Arial;font-size:12pt"> resz@tmYRLabelsOn = False</span></p><p><span style="font-family:Arial;font-size:12pt"> resz@vpHeightF = 0.75</span></p><p><span style="font-family:Arial;font-size:12pt"> resz@vpYF = 0.85</span></p><p style="font-size:12pt;font-family:Arial"><span style="font-family:Arial;font-size:12pt"><br></span></p><p><span style="font-family:Arial;font-size:12pt"> </span></p><p><span style="font-family:Arial;font-size:12pt"> plot1a = gsn_csm_xy(wks,transpose((/(/0.8,0.8,0.8,0.8/),(/0.8,0.8,0.8,0.8/)/)),transpose((/abs(tas_globalave_positiveforcing(0:6:2)),abs(tas_globalave_positiveforcing(0:6:2))/)),resa)</span></p><p><span style="font-family:Arial;font-size:12pt"> plot1b = gsn_csm_xy(wks,transpose((/(/1.2,1.2,1.2,1.2/),(/1.2,1.2,1.2,1.2/)/)),transpose((/abs(tas_globalave_negativeforcing(0:6:2)),abs(tas_globalave_negativeforcing(0:6:2))/)),resb)</span></p><p><span style="font-family:Arial;font-size:12pt">; resa@tiMainString = "HadCM3 -"</span></p><p><span style="font-family:Arial;font-size:12pt"> resa@tmXTLabels = labels1(1)</span></p><p><span style="font-family:Arial;font-size:12pt"> resa@trYMinF = 0.</span></p><p><span style="font-family:Arial;font-size:12pt"> resa@trYMaxF = 1.5</span></p><p><span style="font-family:Arial;font-size:12pt"> resb@trYMinF = 0.</span></p><p><span style="font-family:Arial;font-size:12pt"> resb@trYMaxF = 1.5</span></p><p><span style="font-family:Arial;font-size:12pt"> resz@trYMinF = 0.</span></p><p><span style="font-family:Arial;font-size:12pt"> resz@trYMaxF = 1.5</span></p><p><span style="font-family:Arial;font-size:12pt"> resz@vpXF = deltapl(1)</span></p><p><span style="font-family:Arial;font-size:12pt"> plot2a = gsn_csm_xy(wks,transpose((/(/0.8,0.8,0.8,0.8/),(/0.8,0.8,0.8,0.8/)/)),transpose((/abs(sst_globalave_positiveforcing(0:6:2)),abs(sst_globalave_positiveforcing(0:6:2))/)),resa)</span></p><p><span style="font-family:Arial;font-size:12pt"> plot2b = gsn_csm_xy(wks,transpose((/(/1.2,1.2,1.2,1.2/),(/1.2,1.2,1.2,1.2/)/)),transpose((/abs(sst_globalave_negativeforcing(0:6:2)),abs(sst_globalave_negativeforcing(0:6:2))/)),resb)</span></p><p><span style="font-family:Arial;font-size:12pt"> plot2z = gsn_blank_plot(wks,resz)</span></p><p><span style="font-family:Arial;font-size:12pt">; resa@tiMainString = "Seasonal Cycle"</span></p><p><span style="font-family:Arial;font-size:12pt"> resa@tmXTLabels = labels1(2)</span></p><p><span style="font-family:Arial;font-size:12pt"> resa@trYMinF = 0.</span></p><p><span style="font-family:Arial;font-size:12pt"> resa@trYMaxF = 1.5</span></p><p><span style="font-family:Arial;font-size:12pt"> resb@trYMinF = 0.</span></p><p><span style="font-family:Arial;font-size:12pt"> resb@trYMaxF = 1.5</span></p><p><span style="font-family:Arial;font-size:12pt"> resz@trYMinF = 0.</span></p><p><span style="font-family:Arial;font-size:12pt"> resz@trYMaxF = 1.5</span></p><p><span style="font-family:Arial;font-size:12pt"> resz@vpXF = deltapl(2)</span></p><p><span style="font-family:Arial;font-size:12pt"> plot3a = gsn_csm_xy(wks,transpose((/(/0.8,0.8,0.8,0.8/),(/0.8,0.8,0.8,0.8/)/)),transpose((/abs(trac_globalave_positiveforcing(0:6:2)),abs(trac_globalave_positiveforcing(0:6:2))/)),resa)</span></p><p><span style="font-family:Arial;font-size:12pt"> plot3b = gsn_csm_xy(wks,transpose((/(/1.2,1.2,1.2,1.2/),(/1.2,1.2,1.2,1.2/)/)),transpose((/abs(trac_globalave_negativeforcing(0:6:2)),abs(trac_globalave_negativeforcing(0:6:2))/)),resb)</span></p><p><span style="font-family:Arial;font-size:12pt"> plot3z = gsn_blank_plot(wks,resz)</span></p><p><span style="font-family:Arial;font-size:12pt">; resa@tiMainString = ""</span></p><p><span style="font-family:Arial;font-size:12pt"> resa@tmXTLabels = labels1(3)</span></p><p><span style="font-family:Arial;font-size:12pt"> resa@trYMinF = 0.</span></p><p><span style="font-family:Arial;font-size:12pt"> resa@trYMaxF = 35.</span></p><p><span style="font-family:Arial;font-size:12pt"> resb@trYMinF = 0.</span></p><p><span style="font-family:Arial;font-size:12pt"> resb@trYMaxF = 35.</span></p><p><span style="font-family:Arial;font-size:12pt"> resz@trYMinF = 0.</span></p><p><span style="font-family:Arial;font-size:12pt"> resz@trYMaxF = 35.</span></p><p><span style="font-family:Arial;font-size:12pt"> resz@vpXF = deltapl(3)</span></p><p><span style="font-family:Arial;font-size:12pt"> plot4a = gsn_csm_xy(wks,transpose((/(/0.8,0.8,0.8,0.8/),(/0.8,0.8,0.8,0.8/)/)),transpose((/abs(tas_ohue_positiveforcing(0:6:2)),abs(tas_ohue_positiveforcing(0:6:2))/)),resa)</span></p><p><span style="font-family:Arial;font-size:12pt"> plot4b = gsn_csm_xy(wks,transpose((/(/1.2,1.2,1.2,1.2/),(/1.2,1.2,1.2,1.2/)/)),transpose((/abs(tas_ohue_negativeforcing(0:6:2)),abs(tas_ohue_negativeforcing(0:6:2))/)),resb)</span></p><p><span style="font-family:Arial;font-size:12pt"> plot4z = gsn_blank_plot(wks,resz)</span></p><p><span style="font-family:Arial;font-size:12pt"> overlay(plot1a,plot1b)</span></p><p><span style="font-family:Arial;font-size:12pt"> overlay(plot2a,plot2b)</span></p><p><span style="font-family:Arial;font-size:12pt"> overlay(plot3a,plot3b)</span></p><p><span style="font-family:Arial;font-size:12pt"> overlay(plot4a,plot4b)</span></p><p><span style="font-family:Arial;font-size:12pt"> drawNDCGrid(wks)</span></p><p><span style="font-family:Arial;font-size:12pt"> attplot = gsn_attach_plots(plot1a,(/plot2a,plot3a,plot4a/),at_res,False)</span></p><p><span style="font-family:Arial;font-size:12pt"> draw(plot1a)</span></p><p><span style="font-family:Arial;font-size:12pt"> draw(plot2z)</span></p><p><span style="font-family:Arial;font-size:12pt"> draw(plot3z)</span></p><p><span style="font-family:Arial;font-size:12pt"> draw(plot4z)</span></p><p><span style="font-family:Arial;font-size:12pt">do i = 0, dimsizes(ypos1)-1</span></p><p><span style="font-family:Arial;font-size:12pt"> lb_res@lbFillColors = colors(i)</span></p><p><span style="font-family:Arial;font-size:12pt"> lb_res@lbLabelFontColor = colors(i)</span></p><p><span style="font-family:Arial;font-size:12pt"> gsn_labelbar_ndc(wks,1,labels2(i),0.85,ypos1(i),lb_res)</span></p><p><span style="font-family:Arial;font-size:12pt">end do</span></p><p><span style="font-family:Arial;font-size:12pt">do i = 0, dimsizes(ypos2)-1</span></p><p><span style="font-family:Arial;font-size:12pt"> mk_res@gsMarkerIndex = markrs(i)</span></p><p><span style="font-family:Arial;font-size:12pt"> gsn_polymarker_ndc(wks,0.875,ypos2(i),mk_res)</span></p><p><span style="font-family:Arial;font-size:12pt"> gsn_text_ndc(wks,labels3(i),0.9,ypos2(i),tx_res)</span></p><p><span style="font-family:Arial;font-size:12pt">end do</span></p><p><span style="font-family:Arial;font-size:12pt"> frame(wks)</span></p>_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@mailman.ucar.edu" target="_blank">ncl-talk@mailman.ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="https://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">https://mailman.ucar.edu/mailman/listinfo/ncl-talk</a></blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div><div><span><font color="#888888">Adam Phillips <br></font></span></div><span><font color="#888888">Associate Scientist, </font></span><span><font color="#888888">Climate and Global Dynamics Laboratory, NCAR<br></font></span></div></div><div><span><font color="#888888"><a href="http://www.cgd.ucar.edu/staff/asphilli/" target="_blank">www.cgd.ucar.edu/staff/asphilli/</a> </font></span><span><font color="#888888">303-497-1726 </font></span></div><span><font color="#888888"></font></span><div><div><span><font color="#888888"><br></font></span><div><span><font color="#888888"><a href="http://www.cgd.ucar.edu/staff/asphilli" target="_blank"></a></font></span></div></div></div></div></div></div></div></div></div></div></div>