[ncl-talk] Issue producing panel plot with single overlay plots

Rick Brownrigg brownrig at ucar.edu
Wed Feb 6 05:14:51 MST 2019


Hi Anne,

Its a quirk (feature?) of NCL graphics that plots get mapped onto a
unit-square plotting space. So plots that have a wide or tall aspect end up
with margins along their shorter axis.

What most people do is use Imagemagick's "convert" tool with the "-trim"
option to remove white space along the edges. See this FAQ and search for
"-trim" for examples.

    http://ncl.ucar.edu/FAQ/

What I don't know offhand is whether "convert" can deal with eps. From the
examples of the FAQ, it appears that it does work with postscript, so
hopefully...

Rick

On Wed, Feb 6, 2019 at 2:48 AM Anne <anne.seidenglanz at unive.it> wrote:

> Hi Adam,
>
> thanks for taking the time to look into this issue; yes this has indeed
> worked for me, so I end up with only 1 page instead of 2, great.
> Remains only unknown to me how to adjust the size of the frame around my
> plots so as to have a tight frame around the plots. I have used
>
>   wks_type = "eps"
>
>           wks_type at wkPaperWidthF  = 14.5  ; in inches
>           wks_type at wkPaperHeightF = 12.0  ; in inches
>           wks_type at wkWidth = 1500
>           wks_type at wkHeight = 1500
>
> where PaperWidth and PaperHeight change resulted in changing the size of
> the plots themself (apparently also their resolution), but not the size of
> the frame around. Is there another resource that I need to specify?
>
> Thanks
> Anne
>
> On Tue, Feb 5, 2019 at 9:27 PM Adam Phillips <asphilli at ucar.edu> wrote:
>
>> Hi Anne,
>> Whenever plots are incorrectly being drawn on separate pages or on one
>> page, it is quite likely that it has to do with incorrect calls to draw or
>> frame (either implicitly through a plotting function or explicitly).
>> Calling draw tells NCL to draw the graphic to the workstation, while
>> calling frame tells NCL to finish the current frame/page and to move to the
>> next one. gsn_panel and gsn_csm_contour* functions implicitly call both of
>> those procedures unless the resource list passed in specify otherwise.
>>
>> To simplify your script highlighting draw/frame resources and procedures:
>> res = True
>> res at gsnDraw = False
>> res at gsnFrame = False
>> ...
>> res2                  = True
>> res2 at gsnDraw             = False
>> res2 at gsnFrame            = False
>> ...
>> plot(0) = gsn_csm_contour_map(wks, diff_means_lead0,res)
>> plot0   = gsn_csm_contour(wks, prob_lead0, res2)
>> overlay(plot(0),plot0)
>> draw(plot(0))
>> ; repeat the above 4 lines for plot(1) and plot(2)
>> frame(wks)
>>
>> resP                     = True
>> resP at gsnPanelXWhiteSpacePercent = 5
>> gsn_panel(wks, plot, (/1, 3/), resP)
>>
>> The above calls draw 3 times, and frame once, before gsn_panel is called
>> (where gsnFrame/gsnDraw = True). This results in 2 pages in your output
>> workstation.
>>
>> Try this:
>> res = True
>> res at gsnDraw = False
>> res at gsnFrame = False
>> ...
>> res2                  = True
>> res2 at gsnDraw             = False
>> res2 at gsnFrame            = False
>> ...
>> plot(0) = gsn_csm_contour_map(wks, diff_means_lead0,res)
>> plot0   = gsn_csm_contour(wks, prob_lead0, res2)
>> overlay(plot(0),plot0)
>> ; repeat the above 3 lines for plot(1) and plot(2)
>>
>> resP                     = True
>> resP at gsnPanelXWhiteSpacePercent = 5
>> gsn_panel(wks, plot, (/1, 3/), resP)
>>
>> Hope that all makes sense. If you have further questions let ncl-talk
>> know.
>> Adam
>>
>> On Tue, Feb 5, 2019 at 12:05 PM Anne <anne.seidenglanz at unive.it> wrote:
>>
>>> Hi,
>>>
>>> I am producing 3 polar projection plots in a panel, whereby each single
>>> has overlaid contours (using the 'overlay' procedure); see below, I also
>>> attached the complete script.
>>> In this way I end up with 2 png files, the 1st showing 1 plot that has
>>> all 3 plots overlaid on top of each other, and the 2nd one the actual,
>>> correct, panelled plot. For simple viewing purposes, this is fine for me,
>>> but when it comes to inserting the plots into a word document, also in
>>> another format, like .eps format, then only 1 file is being produced and
>>> when I insert it, only the wrong overlaid 3-in-1 plot appears.
>>>
>>> So my question is:  What is the best way in dealing with overlaid(!)
>>> plots in a panelled configuration, and how to produce them properly (i.e.
>>> format) if one wants to insert them into word? I also tried to reduce the
>>> size of the workstation but wasn't successful, they would still have a
>>> large frame.
>>>
>>> My goal is to have a nice, high quality eps file of my (paneled) plot.
>>>
>>> Thanks for any help,
>>> Anne
>>>
>>>          res at gsnCenterString = "NDJ "+field+" response"
>>>         plot(0) = gsn_csm_contour_map(wks, diff_means_lead0, res)
>>>         plot0   = gsn_csm_contour(wks, prob_lead0, res2)        ; 0.1
>>> shade all areas less than the
>>>         plot0   = gsn_contour_shade(plot0, 0.05, 999.,opt)      ; 0.05
>>> contour level (0.15 for 0.1 contour level)
>>>
>>>         overlay(plot(0),plot0)
>>>         draw(plot(0))
>>>
>>>          res at gsnCenterString = "DJF "+field+" response"
>>>         plot(1) = gsn_csm_contour_map(wks, diff_means_lead1, res)
>>>         plot1   = gsn_csm_contour(wks, prob_lead1, res2)        ; 0.1
>>> shade all areas less than the
>>>         plot1   = gsn_contour_shade(plot1, 0.05, 999.,opt)      ; 0.05
>>> contour level (0.15 for 0.1 contour level)
>>>
>>>         overlay(plot(1),plot1)
>>>         draw(plot(1))
>>>
>>>          res at gsnCenterString = "JFM "+field+" response"
>>>         plot(2) = gsn_csm_contour_map(wks, diff_means_lead2, res)
>>>         plot2   = gsn_csm_contour(wks, prob_JFM, res2)  ; 0.1 shade all
>>> areas less than the
>>>         plot2   = gsn_contour_shade(plot2, 0.05, 999.,opt)
>>>    ;0.05 contour level (0.15 for 0.1 contour level)
>>>
>>>         overlay(plot(2),plot2)
>>>         draw(plot(2))
>>>
>>>         frame(wks)
>>>
>>>
>>>             resP                     = True
>>>             resP at gsnPanelXWhiteSpacePercent = 5
>>>             gsn_panel(wks, plot, (/1, 3/), resP)
>>> _______________________________________________
>>> ncl-talk mailing list
>>> ncl-talk at ucar.edu
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>
>>
>> --
>> Adam Phillips
>> Associate Scientist,  Climate and Global Dynamics Laboratory, NCAR
>> www.cgd.ucar.edu/staff/asphilli/   303-497-1726
>>
>> <http://www.cgd.ucar.edu/staff/asphilli>
>>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190206/6551b700/attachment.html>


More information about the ncl-talk mailing list