Re: polymarker colors

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Mon Feb 06 2012 - 05:43:00 MST

Hi Scott,

There's no way to tie in the polymarker fill color with the color map like you can do with contour levels.

However, I think you have a good start below. The best thing with the gsn_add_polymarker function is to try to draw as many elements as you can with one call, because these routines can be slow if you call them for one point at a time. However, in your case, if you only have around 25 values, this is not a big deal.

I don't know how the "data" variable was constructed, but you could use functions like "ind" or "where" to collect all the data that falls between two levels, and draw all those markers at once.

Also, you can create a dummy filled contour plot in order to get the label bar. You'll need to use contour data that falls outside the range of the marker data, so that no contour lines will be drawn.

See the attached script. Please note there are not enough colors in the colormap the way the contour levels are chosen. You'll probably need to fix this.

--Mary

On Feb 4, 2012, at 12:03 PM, Capps, Scott wrote:

> Greetings,
>
> Extending the polyg_8.ncl example:
>
> http://www.ncl.ucar.edu/Applications/Scripts/polyg_8.ncl
>
> Is it possible to assign a colormap to the polymarker so that the polymarker's fill color is based on the data values?
>
> I would like to assign the fill color from the following colormap:
> gsn_define_colormap(wks,"gui_default")
> colors = gsn_retrieve_colormap(wks)
> colors_new = new((/26,3/),float)
> colors_new(4::,:) = colors(2::,:)
> colors_new(0:1,:) = colors(0:1,:)
> colors_new(2,:) = (/ 1., 1., 1. /) ;Add two white values
> colors_new(3,:) = (/ 1., 1., 1. /) ;Add two white values
> gsn_define_colormap(wks,colors_new)
>
> Here is how I would like the data to map onto the colormap (if I were going to plot contours):
>
> res@lbLabelBarOn = True ; I would like to display the labelBar as well
> res@cnMinLevelValF = 0.
> res@cnMaxLevelValF = 1.4
> res@cnLevelSpacingF = .05
> res@lbLabelStride = 4
>
> However, I am plotting data for point locations only...
>
> Right now, I have to manually map the data to the colorbar via this vector:
>
> tmp = (/13,12,12,4,13,11,9,10,2,10,12,2,12,12,12,11,11,2,9,10,2,2,12,6,9/)
> gsres = True
> do flidx=0,fl_cnt-1
> gsres@gsMarkerIndex = 16 ; Use filled dots for markers.
> gsres@gsMarkerColor = colors_new(tmp(flidx),:)
> gsres@gsMarkerThicknessF = 4.0
> gsn_polymarker(wks,plot,data(flidx,1),data(flidx,0),gsres)
> end do
>
> Is there a way to have the marker color automatically assigned according to the data? And, display the labelbar below?
>
> Thank you,
>
> Scott
> _______________________________________________
> 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 Mon Feb 6 05:43:10 2012

This archive was generated by hypermail 2.1.8 : Mon Feb 06 2012 - 14:24:56 MST