[ncl-talk] xy-plot with markers (depending on a 3. variable)

Rick Brownrigg brownrig at ucar.edu
Tue Jul 14 09:23:09 MDT 2015


Hi Anna,


You have this as your loop code:

   do  i= 1, num_distinct_markers
      res at xyMarkerColors = 2 + i* col_step* t(i)
      ;print(2+i*col_step)
      plot1  = gsn_csm_xy (wks,x_1,y_1,res)
   end do
   draw(plot1)
   frame(wks)

I'm surprised this doesn't report errors, but it is generating
"num_distinct_markers"  unique *plots*, with all the markers of the i-th
plot colored with the i-th color, and plot1 is overwritten each time, with
the last plot prevailing.

What I was suggesting was to create an array of colors
"num_distinct_markers" long, and populate that with your marker colors, as
in :

   markerColors = new((/ num_distinct_markers /), integer)
   do i=0, num_distinct_markers - 1
      markerColors(i) = 2 + i*col_step * t(i)
   end do

   res at xyMarkerColors = markerColors
   plot1 = gsn_csm_xy(wks, x_1, y_1, res)

   draw(plot1)
   frame(wks)

This is untested, without having your data.  Also note that in your
example, you're indexing over 1..num_distinct_markers, whereas I'm looping
from 0..(num_distinct_markers - 1).   I'm not totally sure which is correct
for your case.

Hope that helps...
Rick




On Tue, Jul 14, 2015 at 6:31 AM, Hartmut Bittner <anna at hbittnersth.de>
wrote:

> Hi,
>  I try to realize Ricks idea. But my problem is still that all my markers
> have the same color.
>
> *My problem in generel is: I have 1 data set that consists of a x-
> position ( in my  script: x), a y-position ( in my script: y) and a 3.
> value (for example the temperature, in my script: t). I want to creat  an
> x-y plot with the x/y-position and the marker should be controlled by the
> 3. variable t.  So that I have an 2D-Plot in which 3 variables are
> presented.*
> *For exemple the color of the marker gets red for higher t-values and gets
> green for lower t-values.*
>
> I made an loop over the "xyMarkersColors",but all makers have the same
> color. I want that the makers have different colors. I think for reaching
> this goal in every do loop only 1 markers has to be drawn. So that after n-
> loops all the n xyMarkers are drawn.  How can I reach this? And how can I
> realize the dependent of the markersColors of variable t? If I put t into
> the do loop I get an segmentation fault.
>
>
> Thanks for your help
>
> Anna Lena
>  *Gesendet:* Donnerstag, 09. Juli 2015 um 19:26 Uhr
> *Von:* "Rick Brownrigg" <brownrig at ucar.edu>
> *An:* "Anna Lena Bittner" <anna at hbittnersth.de>
> *Cc:* "ncl-talk at ucar.edu" <ncl-talk at ucar.edu>
> *Betreff:* Re: [ncl-talk] xy-plot with markers (depending on a 3.
> variable)
>     Hi Anna,
>
> One approach is exemplified by example #8 at:
>
> http://ncl.ucar.edu/Applications/polyg.shtml
>
> This approach draws the markers 1-by-1, looping over the marker array and
> setting the colors for each one based upon some criterion.
>
> Another approach, more or less the same amount of effort, is to set up an
> array for the resource "xyMarkerColors" that contains a color value for
> each marker to be drawn. You'd need an array the same length as your xy
> data, and would have to loop over it to fill in each entry with a color
> value based on your 3rd variable.
>
> I note that you are already setting the resource xyMarkerColors with 2
> colors. According to the documentation, if you have more xy data than
> color-values in xyMarkerColors, the remaining markers are drawn with the
> color set by the resource xyMarkerColor (singular) -- the default for that
> resource is whatever the foreground color (typically black).  So what you
> should have gotten in your existing example is one green marker, one blue
> marker, and the remainder black (?)
>
> Make sense?
>
> Rick
>
> On Thu, Jul 9, 2015 at 10:25 AM, Anna Lena Bittner <anna at hbittnersth.de>
> wrote:
>>
>> Hi,
>>
>> I would like to create a xy-plot with markers. The markers should have
>> different colors. The colors should be controlled by a 3. variable.
>> In my plot I already created the makers, but I don't know how to define
>> the color with a 3. variable ( in my case the variable t).
>> I couldn't find a description for this kind of plot. If there is a
>> description on the homepage let me know.
>>
>> I have attached my scripts here.
>>
>>
>> Thanks a lot for your help.
>>
>> Anna Lena
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-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/20150714/f0512de1/attachment.html 


More information about the ncl-talk mailing list