<div dir="ltr">Hi:<div><br></div><div>This should (might) help.</div><div><br></div><div>(Make sure you also use:</div><div><br></div><div>
<p class="gmail-p1"><span class="gmail-s1"> wtype = "png"</span></p>
<p class="gmail-p1"><span class="gmail-s1"> wtype@wkWidth = </span><span class="gmail-s2">7500</span><span class="gmail-s1"> ; this looks better for presentations,</span></p>
<p class="gmail-p1"><span class="gmail-s1"> wtype@wkHeight = </span><span class="gmail-s2">7500</span><span class="gmail-s1"> ; PPT, etc.</span></p>
<p class="gmail-p1"><span class="gmail-s1"> wks = gsn_open_wks(wtype,"traj") )</span></p></div><div><br></div><div>
<p class="gmail-p1"><span class="gmail-s1">panres = True</span></p>
<p class="gmail-p1"><span class="gmail-s1">panres@gsnMaximize = True</span></p>
<p class="gmail-p1"><span class="gmail-s1">panres@gsnPanelRight = 0.98</span></p>
<p class="gmail-p1"><span class="gmail-s1">panres@gsnPanelLeft = 0.02</span></p>
<p class="gmail-p1"><span class="gmail-s1">panres@gsnPanelTop = 0.98</span></p>
<p class="gmail-p1"><span class="gmail-s1">panres@gsnPanelBottom = 0.05</span></p>
<p class="gmail-p2"><span class="gmail-s1"></span><br></p>
<p class="gmail-p1"><span class="gmail-s1"> draw(map)</span></p>
<p class="gmail-p1"><span class="gmail-s1"> frame(wks)</span></p>
<p class="gmail-p1"><span class="gmail-s1"> delete(wks)</span></p>
<p class="gmail-p1"><span class="gmail-s1"> cmd = "convert -trim -geometry 7500x7500 +repage -border 8 -bordercolor white -background white -flatten traj.000001.png traj.000001.png"</span></p>
<p class="gmail-p1"><span class="gmail-s1"> system(cmd)</span></p></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 23, 2017 at 9:04 PM, Alan Brammer <span dir="ltr"><<a href="mailto:abrammer@albany.edu" target="_blank">abrammer@albany.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>There a couple tricks to do this, and I don’t think a complete example anywhere so not sure where it would go though. </div><div><br></div><div><br></div><div>Key resources to really fill a png.</div><div><font face="Andale Mono">res@gsnMaximize = True</font></div><div><font face="Andale Mono">res@gsnBoxMargin = 0 ;; took a lot of digging to find this one. </font><a href="https://www.ncl.ucar.edu/Document/Graphics/Resources/gsn.shtml#gsnBoxMargin" target="_blank">https://www.ncl.ucar.edu/<wbr>Document/Graphics/Resources/<wbr>gsn.shtml#gsnBoxMargin</a></div><div><br></div><div><br></div><div>Key things to remember, </div><div>><span class="m_-9177781201505703834Apple-tab-span" style="white-space:pre-wrap">        </span>"because NCL always draws its graphics to a square canvas, the PNG image will be resized to a square, using the largest of the two values, if you give it non-square values.” </div><div><span class="m_-9177781201505703834Apple-tab-span" style="white-space:pre-wrap">                </span><a href="https://www.ncl.ucar.edu/Applications/resize.shtml" target="_blank">https://www.ncl.ucar.edu/<wbr>Applications/resize.shtml</a> </div><div><br></div><div><br></div><div>So if you want it 1366 wide set both wkWidth and wkHeight to 1366. </div><div>That will fill the png horizontally but leave you with white space at the top and bottom. You can then use “-trim" or “-shave 0x261” (assuming an 844 image height) to crop that border top and bottom. Don’t think there’s a way to produce rectangular plots without white space being included. </div><div><br></div><div>I put a couple of lines at the bottom that should work out the white space and trim it off by itself. </div><div><br></div><div><br></div><div>Good luck, </div><div><br></div><div>Alan</div><div><br></div><div><br></div><div>e.g. with different map coords so different shave numbers. </div><div><br></div><div><div><font face="Andale Mono">wkst = "png"</font></div><div><font face="Andale Mono">wkst@wkWidth = 1366 </font></div><div><font face="Andale Mono">wkst@wkHeight = wkst@wkWidth </font></div><div><font face="Andale Mono">outputname = "filled_png"</font></div><div><font face="Andale Mono"><br></font></div><div><font face="Andale Mono">wks = gsn_open_wks(wkst,outputname)</font></div><div><font face="Andale Mono">mpres := True</font></div><div><font face="Andale Mono">mpres@mpLimitMode = "Corners" </font><span style="font-family:'Andale Mono'">;;; use a cropped area just to identify</span><span class="m_-9177781201505703834Apple-tab-span" style="font-family:'Andale Mono';white-space:pre-wrap">        </span><span style="font-family:'Andale Mono'">the edge of the plot. </span></div><div><font face="Andale Mono">mpres@mpProjection = "mercator"</font></div><div><font face="Andale Mono">mpres@mpPerimOn = False </font></div><div><font face="Andale Mono">mpres@mpLeftCornerLonF = -100</font></div><div><font face="Andale Mono">mpres@mpRightCornerLonF = 100</font></div><div><font face="Andale Mono">mpres@mpRightCornerLatF = 60</font></div><div><font face="Andale Mono">mpres@mpLeftCornerLatF = 0</font></div><div><font face="Andale Mono"><br></font></div><div><font face="Andale Mono">mpres@tmXTOn = False<span class="m_-9177781201505703834Apple-tab-span" style="white-space:pre-wrap">                </span></font><span style="font-family:'Andale Mono'">;;; Here and below are the only ones that actually matter</span></div><div><font face="Andale Mono">mpres@tmXBOn = False<span class="m_-9177781201505703834Apple-tab-span" style="white-space:pre-wrap">                </span></font></div><div><font face="Andale Mono">mpres@tmYROn = False</font></div><div><font face="Andale Mono">mpres@tmYLOn = False</font></div><div><font face="Andale Mono"><br></font></div><div><font face="Andale Mono">mpres@gsnMaximize= True<span class="m_-9177781201505703834Apple-tab-span" style="white-space:pre-wrap">                </span>;;; </font></div><div><font face="Andale Mono">mpres@gsnBoxMargin = 0<span class="m_-9177781201505703834Apple-tab-span" style="white-space:pre-wrap">                </span></font><span style="font-family:'Andale Mono'">;;; this one is the key one to really fill the png</span></div><div><font face="Andale Mono">plot = gsn_csm_map(wks, mpres)</font></div><div><font face="Andale Mono"><br></font></div><div><font face="Andale Mono">getvalues plot</font></div><div><font face="Andale Mono"> "vpHeightF": vpHF</font></div><div><font face="Andale Mono"> "vpWidthF": vpWF ;; should be 1.</font></div><div><font face="Andale Mono">end getvalues</font></div><div><font face="Andale Mono"> </font></div><div><font face="Andale Mono">image_height = 1366*vpHF</font></div><div><font face="Andale Mono">half_margin = floor(0.5* (wkst@wkHeight-image_height) )</font></div><div><font face="Andale Mono"><br></font></div><div><font face="Andale Mono">;system("convert -shave 0x"+half_margin+" "+outputname+"."+wkst+" shaved.png")</font></div><div><font face="Andale Mono">;; or</font></div><div><font face="Andale Mono">system("mogrify -shave 0x"+half_margin+" "+outputname+"."+wkst) ;; sister to convert, replaces original image</font></div></div><div><font face="Andale Mono"><br></font></div><div><br></div><div><br></div><div><br></div><div><br><div>
<div style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word"><div style="color:rgb(0,0,0);font-family:Helvetica;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:-webkit-auto;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word"><span class="m_-9177781201505703834Apple-style-span" style="border-collapse:separate;font-variant-ligatures:normal;font-variant-east-asian:normal;line-height:normal;border-spacing:0px"><div style="word-wrap:break-word">##############################<br>Alan Brammer,<div>Post-Doc Researcher</div><div><br></div><div>Department of Atmospheric and Environmental Sciences,<br>University at Albany, State University of New York, Albany, NY, 12222<div><a href="mailto:abrammer@albany.edu" target="_blank">abrammer@albany.edu</a><br>##############################</div></div></div></span></div></div>
</div><div><br class="m_-9177781201505703834webkit-block-placeholder"></div><div><br></div><div><br></div>
<br><div><blockquote type="cite"><div><div class="h5"><div>On 22 May 2017, at 12:31, Roussan <<a href="mailto:rousslucas@gmail.com" target="_blank">rousslucas@gmail.com</a>> wrote:</div><br class="m_-9177781201505703834Apple-interchange-newline"></div></div><div><div><div class="h5"><div dir="ltr"><div>Hello,</div><div>I would like to plot contours in full page at a given size (1366 x 844),</div><div>with no margins, no white spaces, just the plot at this dimmension.</div><div>Is it possible, or do I have to use imagemaick or graphicsmagick to crop the output image ?<br></div><div>(I have disabled titles and labels.)</div><div><br></div><div> Here is the piece of code :</div><div><br></div><div> waveheight = fin->HTSGW_P0_L1_GLL0</div><div> delete(waveheight@long_name)</div><div> delete(waveheight@units)</div><div><br></div><div> wavedir = fin->DIRPW_P0_L1_GLL0</div><div> delete(wavedir@long_name)</div><div> delete(wavedir@units)</div><div><br></div><div> wks_type = "png"</div><div> wks_type@wkWidth = 1366</div><div> wks_type@wkHeight = 844</div><div> wks = gsn_open_wks(wks_type,outfile)</div><div> </div><div> vres = True<br></div><div> vres@vcRefAnnoOn = False</div><div><br></div><div> res = True</div><div> res@gsnMaximize = True</div><div> res@lbLabelBarOn = False</div><div> res@lbTitleOn = False</div><div> vres@lbLabelBarOn = False</div><div> vres@lbTitleOn = False</div><div><br></div><div> plot = gsn_csm_contour_map(wks,<wbr>waveheight,res)</div><div> plot_ov = gsn_csm_vector_scalar(wks, udir(:,:), vdir(:,:),waveheight,vres)</div><div><br></div><div> overlay(plot,plot_ov) ; overlay the U-wind plot on the temperature plot</div><div><br></div><div> draw(plot) ; draw the temperature plot (with the U-wind plot overlaid)</div><div> frame(wks) ; advance the frame</div><div><br></div><div><br></div><div><br></div><div><br></div><div>You will can see what I can achieve in attachement.</div><div>Thank you in advance</div><div>Ross.</div></div>
</div></div><span id="m_-9177781201505703834cid:0F98AF82-E0C3-4B46-B2DB-C4CA1A79F0B2@eas.albany.edu"><out.png></span>_____________________<wbr>__________________________<br>ncl-talk mailing list<br><a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>List instructions, subscriber options, unsubscribe:<br><a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/<wbr>mailman/listinfo/ncl-talk</a><br></div></blockquote></div><br></div></div><br>______________________________<wbr>_________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/<wbr>mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Barry H. Lynn, Ph.D<div><div>Senior Lecturer,</div><div><div><span style="color:rgb(136,136,136)">The Institute of the Earth Science, </span><br style="color:rgb(136,136,136)"><span style="color:rgb(136,136,136)">The Hebrew University of Jerusalem, </span><br style="color:rgb(136,136,136)"><span style="color:rgb(136,136,136)">Givat Ram, Jerusalem 91904, Israel </span><br style="color:rgb(136,136,136)"></div><span style="color:rgb(136,136,136)">Tel: 972 547 231 170</span><br style="color:rgb(136,136,136)"><span style="color:rgb(136,136,136)">Fax: (972)-25662581</span></div></div><div><span style="color:rgb(136,136,136)"><br></span></div><div>C.E.O, Weather It Is, LTD<br>Weather and Climate Focus<br><a href="http://weather-it-is.com" target="_blank">http://weather-it-is.com</a><br>Jerusalem, Israel<br>Local: 02 930 9525<br>Cell: 054 7 231 170<br>Int-IS: x972 2 930 9525<br>US 914 432 3108<br></div></div></div>
</div>