Re: panel plots

From: Kyle Griffin <ksgriffin2_at_nyahnyahspammersnyahnyah>
Date: Fri Mar 14 2014 - 09:26:46 MDT

Ah, I think I understand what you want to do. This is going to be a bit
more complicated. You're looking to overlay 3 plots on top of each other to
form a single plot, and then panel a total of six of these combined plots.
The challenge is your system doesn't use traditional overlay methods, and
thus is not readily doable with gsn_panel. You do have the option of
attempting to panel things manually, setting vpXF, vpYF, vpXWidthF, and
vpYWidthF manually for each "panel" plot in order to get them all to line
up within the workspace, but this will require a bit of experimentation and
trial and error to get the sizes correct.

I'm going to throw out some untested ideas here, so I apologize in advance
if they don't work or aren't quite perfect.

What I would recommend is making three arrays of six graphics...

plots_box = new(6,graphic)
plots_xy1 = new(6,graphic)
plots_xy2 = new(6,graphic)

With this, make each individual component of your plots and plot each with
gsn_panel. What you can then do is use the same technique you have above to
try and overlay the already-paneled plots. Essentially, you'll be using the
same code as above but with gsn_panel calls where the gsn_csm_xy calls are
currently. Of course, you'll have to have all six of your calls to
gsn_csm_xy before you call gsn_panel as well.

It'll look something like

plots_box(0) = gsn_csm_xy(...)
plots_box(1) = gsn_csm_xy(...)
....
gsn_panel(wks,plots_box,(/2,3/),pres)

plots_xy1(0) = gsn_csm_xy(...)
plots_xy1(1) = gsn_csm_xy(...)
....
gsn_panel(wks,plots_xy1,(/2,3/),pres)

plots_xy2(0) = gsn_csm_xy(...)
plots_xy2(1) = gsn_csm_xy(...)
....
gsn_panel(wks,plots_xy2,(/2,3/),pres)

If the figures are the same size, including axes/colorbars/titles, they
could line up and produce the result you desire. More likely, they are
going to be slightly out of alignment and the whole figure will look
terrible. You'll also have to try to ensure that gsn_panel isn't framing
the image with each call with pres@gsnFrame = False, although I'm not
certain you can set that resource for a panel plot.

You've got a complicated but - in theory - doable task here. I'm not
particularly well versed in moving things around the viewport manually, so
hopefully others can chime in here. My last word of advice is to consider
making each plot like the one you first sent us and use an external program
to stitch them together as a panel - it might be quicker/simpler than
learning how to do so in NCL.

Good luck!

Kyle

----------------------------------------
Kyle S. Griffin
Department of Atmospheric and Oceanic Sciences
University of Wisconsin - Madison
Room 1421
1225 W Dayton St, Madison, WI 53706
Email: ksgriffin2@wisc.edu

On Fri, Mar 14, 2014 at 9:51 AM, mamadoulamine.mbaye@ucad.edu.sn <
mamadoulamine.mbaye@ucad.edu.sn> wrote:

> Hi,
>
> Karin has proposed this, and also I have tried before, It did not work
> that's why I removed it in the script.
>
> I repeat that I did not want to separate them (plot(0),plot(1), and
> plot(2)). the plots (1) &(2) have the same Y axis, and both have the same x
> axis with plot (0). You can see in the toto.pdf file, I have a panel of 3
> figures and each figure have 3 plots( 1 barchart and 2 curves).
>
> by doing* gsn_panel*(wks,plot,(/3,1/),pres): this means that 3 plots in 3
> raws.
>
>
> I want to add 6 plots others like this (this is not in the script) . I
> was trying to make sure I can panel it without separating them and put it
> in a particular place(by using top, bottom ,left and right resources panel
> ) before adding other data sets.
>
> Maybe I have to put the general scripts with 9 data sets
>
> Best Regards,
>
> Mamadou
>
>
>
>
> ------------------------------
> *De :* windrunnerxc@gmail.com <windrunnerxc@gmail.com> de la part de Kyle
> Griffin <ksgriffin2@wisc.edu>
> *Envoyé :* vendredi 14 mars 2014 06:13
> *À :* mamadoulamine.mbaye@ucad.edu.sn
> *Cc :* ncl-talk
> *Objet :* Re: [ncl-talk] panel plots
>
> Hi Mamadou,
>
> It looks like you are creating all of your plots for paneling, but not
> actually paneling them. You'll need to add a call to gsn_panel at the end,
> likely instead of the maximize_output call you have currently.
>
> https://www.ncl.ucar.edu/Document/Graphics/Interfaces/gsn_panel.shtml
>
> This call will create the graphics scaled down to the appropriate sizes
> and call the appropriate draw and frame functions as well. You even seem to
> be setting panel resources with the attributes of pres, but not actually
> using them. While you may need to add further attributes to pres in order
> to get your plot to look perfect, simply adding a call similar to the one
> below should get you going...
>
> *gsn_panel*(wks,plot,(/3,1/),pres)
>
> This should give you a plot of all the plots you've saved in your variables plot(0), plot(1), and plot(2) in a paneled plot with 3 rows in 1 column using attributes from pres.
>
> You can look at other panel plot examples here, if you want to figure out some additional settings to set with attributes:
>
> https://www.ncl.ucar.edu/Applications/panel.shtml
>
>
> Let the list know if you need any further help...
>
>
>
>
> Kyle
>
>
> ----------------------------------------
> Kyle S. Griffin
> Department of Atmospheric and Oceanic Sciences
> University of Wisconsin - Madison
> Room 1421
> 1225 W Dayton St, Madison, WI 53706
> Email: ksgriffin2@wisc.edu
>
>
> On Fri, Mar 14, 2014 at 4:33 AM, mamadoulamine.mbaye@ucad.edu.sn <
> mamadoulamine.mbaye@ucad.edu.sn> wrote:
>
>> Hi,
>>
>> I would like to do a panel of 3 plots like the one joined. If I use plot
>> = new(3,graphic), and replace ba_plot, xy_plot,and xy_plot1 by plot(0),
>> plot(1), and plot(2), it doesn't not work. Here is the script I use to
>> generate this figure (with 3 plots):
>>
>>
>>
>> month=ispan(1,12,1)
>> wks = gsn_open_wks("x11","toto")
>>
>> ;---Set resources common to both plots
>> res = True
>> res@gsnFrame = False
>> res@gsnDraw = False
>>
>> res@trXMinF = 0
>> res@trXMaxF = 13
>>
>>
>> ;----------------------------------------- Bar chart
>> ----------------------------------------------------------------------------
>>
>> bres = res
>> bres@gsnXYBarChart = True
>> bres@gsnXYBarChartBarWidth = 0.77
>> bres@gsnXYBarChartColors = "blue"
>> bres@tmYROn = False
>> bres@gsnYRefLine = 0.
>> bres@trYMaxF = 30
>> bres@trYMinF = -50
>> bres@tiMainFontHeightF = 0.03
>>
>> bar_plot = gsn_csm_xy (wks,month,pr1,bres)
>> ;--- for the legend
>> lbres = True
>> lbres@lbLabelFontHeightF = 0.015
>> lbres@lbFillColors = "blue"
>> lbres@vpHeightF = .015
>> lbres@vpWidthF = .15
>> lbres@lbPerimOn = False
>> lbres@lbFillPattern = "SolidFill"
>> lbres@lbMonoFillPattern = True
>> label= "Rainfall change"
>> gsn_labelbar_ndc(wks,1,label,0.2,0.78,lbres)
>>
>> ;---Get viewport values for bar plot
>> getvalues bar_plot
>> "vpXF" : vpx
>> "vpYF" : vpy
>> "vpWidthF" : vpw
>> "vpHeightF" : vph
>> end getvalues
>>
>> ;--------------------------XY curve resources seasonal
>> cycle---------------------------------------------------------------
>> xyres = res
>> xyres@xyLineThicknessF = 6.0
>> xyres@xyLineColor = "red"
>> xyres@trYMaxF = 7.
>> xyres@trYMinF = 0
>>
>> ;---Turn off bottom, top, and left tickmarks
>> xyres@tmXBOn = False
>> xyres@tmXTOn = False
>> xyres@tmYLOn = False
>> xyres@tmYROn = True
>> xyres@tmYRLabelsOn = True
>>
>> ;---Set a title on right Y axis seasonal cycle
>> xyres@tiYAxisString = "Rainfall (mm/day)"
>> xyres@tiYAxisSide = "Right"
>>
>> ; Make sure XY curve is drawn in same viewport space as bar plot
>> ; Note there is no attempt to mathematically map the left and
>> ; right Y axis to each other.
>> xyres@vpXF = vpx
>> xyres@vpYF = vpy
>> xyres@vpWidthF = vpw
>> xyres@vpHeightF = vph
>>
>> xyres@pmLegendDisplayMode = "Always"
>> xyres@pmLegendSide = "Top"
>> xyres@pmLegendParallelPosF = 0.55
>> xyres@pmLegendOrthogonalPosF = -0.148
>>
>> xyres@pmLegendWidthF = 0.1
>> xyres@pmLegendHeightF = 0.1
>> xyres@lgLabelFontHeightF = .015
>> xyres@lgPerimOn = False
>> xyres@xyLineThicknesses = "12.0"
>> xyres@xyExplicitLegendLabels ="RCP45_2011-2040"
>>
>> xy_plot = gsn_csm_xy (wks,month,pr2,xyres)
>>
>>
>> ;============= Add a second curve on the
>> right==============================
>> xyres@pmLegendDisplayMode = "Always"
>> xyres@pmLegendSide = "Top"
>> xyres@pmLegendParallelPosF = 0.87
>> xyres@pmLegendOrthogonalPosF = -0.148
>>
>> xyres@pmLegendWidthF = 0.1
>> xyres@pmLegendHeightF = 0.1
>> xyres@lgLabelFontHeightF = .015
>> xyres@lgPerimOn = False
>> xyres@xyLineThicknesses = "12.0"
>> xyres@xyExplicitLegendLabels ="historical"
>>
>> xyres@xyLineColor = "green"
>> xy_plot1 = gsn_csm_xy (wks,month,pr3,xyres)
>>
>>
>> ;=============================================================
>> pres = True
>> pres@gsnMaximize = True
>> maximize_output(wks,pres)
>>
>>
>> I would just want to know how to panel this, and after I will add 2
>> others like this plot at the same page.
>>
>> Best Regards,
>>
>> Mamadou
>>
>>
>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Mar 14 09:27:19 2014

This archive was generated by hypermail 2.1.8 : Fri Mar 14 2014 - 15:08:52 MDT