[Thread Prev][Thread Next][Index]

Re: [ferret_users] Customizing a shade plot with specified value range and color



Hi Swetha,

Yes you can do this. It will require some features that might not be well known to a lot of users. You will need to know how to specify a particular set of color-levels that don't use the /levels=(lo,hi,del) syntax, and you will need to define a custom color palette.  I'll show this with some simple examples to try.

Color levels can be specified with a lot of flexibility.  Here is the whole list of the settings, https://ferret.pmel.noaa.gov/Ferret/documentation/users-guide/customizing-plots/CONTOURING#_VPINDEXENTRY_852

For a FILL plot (recall that FILL is an alias for CONTOUR/FILL), the levels specified using the /LEVELS= qualifier are where the contour lines are drawn, with the color fill between the lines. For a SHADE plot, the levels are the boundaries between the colors on the colorbar with grid cells colored accordingly.  The most common way to set levels is with /LEVELS=(lo,hi,del).

Compare these two plots, which use a variable I have made up.

yes? fill/line/key/x=1:5/y=1:5/level=(2,10,1) x+y
yes? shade/x=1:5/y=1:5/
level=(2,10,1) x+y

Now try using a set of individual levels. This is the style you will want. Try these commands:

yes? fill/line/key/x=1:5/y=1:5/level=(2.5)(5.2)(6)(7.1)(10) x+y
yes? shade/x=1:5/y=1:5/level=(2.5)(5.2)(6)(7.1)(10) x+y

For your variable you will probably use /level=(-0.2)(0)(0.2)(0.3)(0.6)(1)

It looks as if you want to leave some blank space between 0.2 and 0.3.  I think the best way to do that is to color that piece of the plot using white, though there might also be ways to do it by overlaying two different SHADE commands.  This way the white will show up on your color key.

To define your color palette, you need a color palette that is a "by level" color palette. For the details of the different kinds of color palettes see https://ferret.pmel.noaa.gov/Ferret/documentation/users-guide/customizing-plots/COLOR#_VPID_247

Try this to see what a by-level color palette does:

yes? shade/x=1:5/y=1:5/lev=(2.5)(5.2)(6)(7.1)(10)/palette=ten_by_levels x+y

The first color in the palette is assigned to the first level, the second color is assigned to the second level, and so on.  You can create your own palette of this type, making the colors blue, then yellow, etc.

You can search the pre-installed color palettes using the Unix command-line command "Fpalette".  Search for the palettes that include "level" in their name

> Fpalette level
* * * * * * * * in /home/ansley/my_pyferret/ppl
...
ten2_levels.spk:
ten_bright_levels.spk:
ten_by_levels.spk:
ten_reordered_levels.spk:
thirty_by_levels.spk:

 
I would start with one of these. Copy it from where it is installed on your system to your local directory, and rename it. Edit your palette file so that color 1 is blue, color 2 is yellow, color 3 is white (for that gap between 0.2 and 0.3), color 4 is orange, and color 5 is green.  If I'm making a palette, I use the Fpalette command a lot.  Maybe I want a different orange than what I have, so

> Fpalette orange

and then look in those files to see how different colors are defined.

The palette file you make can either be in the local directory where you are when running PyFerret, or you can put it in any directory and make sure that that directory is included in the environment variable FER_PALETTE.

Ansley


On 12/21/2021 12:14 AM, Swetha sivakumar wrote:
Hello all

I want to make a shade plot, value ranges from -0.2 to 1 , but want to customize the plot as below
(-0.2 to 0) - Blue
(0 to 0.2) -yellow
(0.3 to 0.6) - orange
(0.6 to 1) - green

Is there any way in ferret to customize shade plot as above.

TIA
Swetha

[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement