NOAA-PMEL / PyFerret

The PyFerret program and Python module from NOAA/PMEL
https://ferret.pmel.noaa.gov/Ferret/
The Unlicense
59 stars 22 forks source link

Support custom colors in the /GRAT= option #51

Open karlmsmith opened 6 years ago

karlmsmith commented 6 years ago

After fixing issue #50 to properly parse custom colors in the /GRAT= optino, ends up custom colors are not supported for graticules. At this time a warning message is issued and black is used instead.

yes? PLOT/COLOR=(60,50,20)/GRATICULE="(DASH,COLOR=(100,20,50))" I[I=1:50]
           *** NOTE: Only standard line colors and thicknesses are accepted at this time.  Using black.
           *** NOTE: Only standard line colors and thicknesses are accepted at this time.  Using black.

and the plot actually is a red (ie, incorrect color) line with black graticules.

yes? PLOT/COLOR=(60,50,20)/GRATICULE="(DASH,COLOR=blue)" I[I=1:50]

gives the correct colors for the line and the graticules. The following also works correctly:

yes? set mode linecolors 7
           *** NOTE: New # of line colors will take effect on next new window: SET WIN/NEW then define pen colors
yes? set win /new
yes? ppl color 7,100,20,50
yes? PLOT/COLOR=(60,50,20)/GRATICULE="(DASH,COLOR=7)" I[I=1:50]

which was given as a suggested work-around on the email list.

PBrockmann commented 3 years ago

Would be nice to have control on gratucule color indeed.

yes? shade/graticule=(dash, color=(70,70,70), opacity=0.3) var

Or add a lightgray and a gray in default colors ready to be used.

ryofurue commented 2 years ago

It would be nice if the current restriction is explicitly documented in the official manual. We've recently had this question: https://www.pmel.noaa.gov/maillists/tmap/ferret_users/fu_2019/msg01105.html in the mailing list.

ACManke commented 2 years ago

Yes, this should be documented. I also think it would be less confusing if this were handled as an ERROR instead of a warning. The warning messages (NOTE's) can easily be lost in the Ferret output, and because this syntax is not allowed it should be an error.

Note that PyFerret does allow both a custom color and an opacity in the syntax "PPL COLOR" so in the example in the description above we could have

yes? ppl color 7,100,20,50
yes? PLOT/COLOR=(60,50,20)/GRATICULE="(DASH,COLOR=7)" I[I=1:50]

! or 

! Define a gray color with, 50% opacity 
yes? ppl color 7,50,50,50,50
yes? PLOT/COLOR=(60,50,20)/GRATICULE="(DASH,COLOR=7)" I[I=1:50]
ACManke commented 1 year ago

The original issue here was resolved in 2022, so that colors for graticule lines can be completely customized.

The extra color definitions needed to customize horizontal and vertical graticule lines are added in set_graticules.F. The opacity can be set using the 4-argument color specifier /graticule=(color=(r,g,b,a)) - though I don't know how useful that will be.

Examples are added in the demo script graticules_demo.jnl (as of today in the fork ACManke).

Also, it would be good if the documentation were changed; it would need to be done for all of the plot commands, CONTOUR, PLOT, VECTOR, SHADE, and POLYGON.

e.g. under the CONTOUR command currently it says,

The syntax is

yes? CONTOUR/GRATICULE[=line or dash,COLOR=,THICKNESS=] var

where the default is a thin, solid black line. The line colors available are Black, Red, Green, Blue, LightBlue, Purple, and White. 
The thickness codes are 1, 2, or 3 and as for plot lines, thickness=1 is a thin line, thickness=3 is the thickest, and THICK 
specified with no value defaults to thickness=2. For clarity the arguments to GRAT may be placed in parentheses

yes? CONTOUR/GRAT sst ! default graticules
yes? CONTOUR/GRAT=(LINE,COLOR=red,THICK=3) sst
yes? CONTOUR/GRAT=(DASH,COLOR=lightblue) sst
yes? CONTOUR/FILL/GRAT=(DASH,COLOR=white) sst

This could be changed to say,

The syntax is

yes? CONTOUR/GRATICULE[=line or dash,COLOR=,THICKNESS=] var

where the default is a thin, solid black line. The line colors available are Black, Red, Green, Blue, LightBlue, Purple, and White. 
 The line color may alternatively be given with an (r,g,b,a) specification as is the case for line plots and contour lines. The 
 thickness codes are 1, 2, or 3 and as for plot lines, thickness=1 is a thin line, thickness=3 is the thickest, and THICK specified 
 with no value defaults to thickness=2. For clarity the arguments to GRAT may be placed in parentheses

yes? CONTOUR/GRAT sst ! default graticules
yes? CONTOUR/GRAT=(LINE,COLOR=red,THICK=3) sst
yes? CONTOUR/GRAT=(DASH,COLOR=lightblue) sst
yes? CONTOUR/FILL/GRAT=(DASH,COLOR=white) sst
yes? CONTOUR/FILL/GRAT=(thick=3,COLOR=(60,60,60)) sst
ryofurue commented 1 year ago

The opacity can be set using . . . - though I don't know how useful that will be.

If adding graticules is possible in overlays, then opacity would be useful. I sometimes want to plot graticules over an existing shading. For example, I would plot a shading of an oceanic variable, add latitude and longitude lines, and then overlay another variable in contour lines. I'd like those latitude and longitude lines to be half transparent.