[ncl-talk] multiple color markers with single array data (XY plot)

S Br sbr.climate at gmail.com
Mon Jul 22 02:59:58 MDT 2019


Hi Karin,
Thanks for your detail explanation and a nice script. This worked fine
for me but I thought there would have been a simpler way to do that.
Thanks for your time.

Best,
SB

On Sat, Jul 20, 2019 at 5:12 PM Karin Meier-Fleischer <
meier-fleischer at dkrz.de> wrote:

> Ok. I would recommend to create a blank plot and add the markers to the
> plot. The polymarker resources have to be changed from xyMarker... to
> gsMarker..!
>
> Here is an example which draws each data point as a triangle in a
> different color.
>
> begin
>
>   x = (/0.205, 0.280, 0.211, 0.229, 0.283, 2.141, 2.160/)  ;-- your x-data
>   y = (/0.155, 0.050, 0.151, 0.159, 0.053, 0.151, 0.150/)  ;-- your y-data
>
>   colors = (/"red","green","blue","black","orange","magenta","brown"/) ;--
> color array
>
>   wks = gsn_open_wks("x11","plot_markers") ;-- graphics output type
>
>   res                     = True
>   res at gsnDraw             = False           ;-- don't draw the plot, yet
>   res at gsnFrame            = False           ;-- don't advance frame, yet
>
>   res at trXMinF             = 0.0             ;-- x-axis minimum
>   res at trXMaxF             = 2.3             ;-- x-axis maximum
>   res at trYMinF             = 0.04            ;-- y-axis minimum
>   res at trYMaxF             = 0.18            ;-- y-axis maximum
>
>   plot = gsn_csm_blank_plot (wks, res)      ;-- create a blank plot
>
>   mres                    = True
>   mres at gsMarkerIndex      = 10              ;-- choose marker types
>   mres at gsMarkerSizeF      = 0.02            ;-- choose marker size
>   mres at gsMarkerThicknessF = 3.0             ;-- choose marker thickness
>
>   do i=0,dimsizes(x)-1
>      mres at gsMarkerColor   = colors(i)       ;-- set marker colors
>      id = unique_string("mark")             ;-- create unique id
>      plot@$id$ = gsn_add_polymarker(wks,plot,x(i),y(i),mres) ;-- add
> marker to plot
>   end do
>
>   draw(plot)    ;-- draw the plot
>   frame(wks)    ;-- advance the frame
>
> end
>
> -Karin
>
>
> Am 20.07.19 um 09:08 schrieb S Br:
>
> Hi Karin,
> I have tried this simple script but still it doesn't work. I can't produce
> the markers with different colors.
>
> Thanks.
> SB
>
> begin
>
>   x = (/0.205, 0.280/)
>   y = (/0.155, 0.050/)
>
>   wks = gsn_open_wks("X11","Test_fig")             ; send graphics to PNG
> file
>
>   res                     = True
>   res at gsnDraw             = False            ; don't draw
>   res at gsnFrame            = False            ; don't advance frame
>
>   res at xyMarkLineModes  = (/"Markers","Markers"/)   ;-- set mark line mode
> for both variables
>   res at xyMarkers        = (/ 10, 16/)               ;-- choose marker types
>   res at xyMarkerColors   = (/"red","blue"/)          ;-- choose marker
> colors
>
>   plot                    = gsn_csm_xy (wks,x,y,res)
>
> draw(plot)
> frame(wks)
> end
>
> On Fri, Jul 19, 2019 at 4:00 PM Karin Meier-Fleischer via ncl-talk <
> ncl-talk at ucar.edu> wrote:
>
>> Hi SB,
>>
>> to use two different markers with different colors set the resources of
>> xyMarkLineModes and xyMarkers like below.
>>
>>   res at xyMarkLineModes  = *(/"Markers","Markers"/)*   ;-- set mark line
>> mode for both variables
>>   res at xyMarker*s*        = (/ 10, 16/)               ;-- choose marker
>> types
>>   res at xyMarkerColors   = (/"red","blue"/)          ;-- choose marker
>> colors
>>
>> -Karin
>>
>> Am 19.07.19 um 16:41 schrieb S Br via ncl-talk:
>>
>> Hi All,
>> Is it possible to draw markers with different color in a XY plot. I am
>> trying as given below but doesn't work.
>>
>> Thanks.
>> SB
>>
>> x = (/0.205, 0.280, 0.211, 0.229, 0.283, 2.141, 2.160/)
>> y = (/0.155, 0.050, 0.151, 0.159, 0.053, 0.151, 0.150/)
>>
>>  res at xyMarkLineModes     = "Markers"
>>    res at xyMarker            = 9
>>    res at xyMarkerSizeF       = 0.02                        ; default 0.01
>>    res at xyMarkerThicknessF  = 2.0                         ; default 1.00
>>    res at xyMarkerColors         =  (/ "green4", "red", "blue", "orange", \
>>                                    "cyan2", "darkorchid2", "brown"/)
>>
>>    plot                    = gsn_csm_xy (wks,x,y,res)
>>
>> draw(plot)
>> frame(wks)
>> end
>>
>> _______________________________________________
>> ncl-talk mailing listncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>> _______________________________________________
>> 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/20190722/b9485910/attachment.html>


More information about the ncl-talk mailing list