Difference between revisions of "Module:Weather"

From blackwiki
Jump to navigation Jump to search
blackwiki>Johnuniq
(fix bug in color algorithm in an edit (27 August 2015) to Template:Weather box/colt (which this module copied))
blackwiki>Johnuniq
(make color handling more general so it can process different palettes; include show function to output graphs/table of colors)
Line 5: Line 5:
 
local MINUS = '−'  -- Unicode U+2212 MINUS SIGN
 
local MINUS = '−'  -- Unicode U+2212 MINUS SIGN
  
local function temperature_style(value)
+
local function temperature_style(palette, value, out_rgb)
 
-- Return style for a table cell based on the given value which
 
-- Return style for a table cell based on the given value which
 
-- should be a temperature in °C.
 
-- should be a temperature in °C.
local function show(bg, fg)
+
local function style(bg, fg)
if not fg and value and (value < -23.3 or value >= 37.8) then
+
local min, max = unpack(palette.white or { -23, 35 })
 +
if not fg and value and (value < min or value >= max) then
 
fg = 'FFFFFF'
 
fg = 'FFFFFF'
 
end
 
end
Line 20: Line 21:
 
end
 
end
 
if type(value) ~= 'number' then
 
if type(value) ~= 'number' then
return show('FFFFFF', '000000')
+
return style('FFFFFF', '000000')
 
end
 
end
local red, green, blue
+
local rgb = out_rgb or {}
if value < -42.75 or value > 60 then
+
for i, v in ipairs(palette) do
red = 0
+
local a, b, c, d = unpack(v)
elseif value < 4.47 then
+
if value <= a then
red = 5.4 * (42.75 + value)
+
rgb[i] = 0
elseif value > 41.5 then
+
elseif value < b then
red = 13.78 * (60 - value)
+
rgb[i] = (value - a) * 255 / (b - a)
else
+
elseif value <= c then
red = 255
+
rgb[i] = 255
 +
elseif value < d then
 +
rgb[i] = 255 - ( (value - c) * 255 / (d - c) )
 +
else
 +
rgb[i] = 0
 +
end
 
end
 
end
if value < -42.75 or value > 41.5 then
+
return style(string.format('%02X%02X%02X', rgb[1], rgb[2], rgb[3]))
green = 0
 
elseif value < 4.47 then
 
green = 5.4 * (42.75 + value)
 
elseif value > 4.5 then
 
green = 6.89 * (41.5 - value)
 
else
 
green = 255
 
end
 
if value < -90 or value > 23 then
 
blue = 0
 
elseif value < -42.78 then
 
blue = 5.4 * (90 + value)
 
elseif value > 4.5 then
 
blue = 13.78 * (23 - value)
 
else
 
blue = 255
 
end
 
return show(string.format('%02X%02X%02X', red, green, blue))
 
 
end
 
end
  
local function format_cell(value, intext, outtext)
+
local function format_cell(palette, value, intext, outtext)
 
-- Return one line of wikitext to make a cell in a table.
 
-- Return one line of wikitext to make a cell in a table.
 
if not value then
 
if not value then
Line 64: Line 52:
 
text = intext
 
text = intext
 
end
 
end
return '| ' .. temperature_style(value) .. ' | ' .. text .. '\n'
+
return '| ' .. temperature_style(palette, value) .. ' | ' .. text .. '\n'
 
end
 
end
  
Line 106: Line 94:
 
end
 
end
  
local function temperature_row(row, inunit, swap)
+
local function temperature_row(palette, row, inunit, swap)
 
-- Return 13 lines specifying the style/content of 13 table cells.
 
-- Return 13 lines specifying the style/content of 13 table cells.
 
-- Input is 13 space-separated words, each a number (°C or °F).
 
-- Input is 13 space-separated words, each a number (°C or °F).
Line 125: Line 113:
 
break
 
break
 
end
 
end
results[n] = format_cell(process_temperature(word, inunit, swap))
+
results[n] = format_cell(palette, process_temperature(word, inunit, swap))
 
end
 
end
 
for i = n + 1, nrcol do
 
for i = n + 1, nrcol do
Line 131: Line 119:
 
end
 
end
 
return table.concat(results)
 
return table.concat(results)
 +
end
 +
 +
local palettes = {
 +
-- A background color entry in a palette is a table of four numbers,
 +
-- say { 11, 22, 33, 44 } (values in °C).
 +
-- That means the color is 0 below 11 and above 44, and is 255 from 22 to 33.
 +
-- The color rises from 0 to 255 between 11 and 22, and falls between 33 and 44.
 +
cool = {
 +
{ -42.75,  4.47, 41.5, 60  },
 +
{ -42.75,  4.47,  4.5, 41.5 },
 +
{ -90  , -42.78,  4.5, 23  },
 +
white = { -23.3, 37.8 },
 +
},
 +
cool2 = {
 +
{ -42.75,  4.5 , 41.5, 56  },
 +
{ -42.75,  4.5 ,  4.5, 41.5 },
 +
{ -90  , -42.78,  4.5, 23  },
 +
white = { -23.3, 35 },
 +
},
 +
cool2avg = {
 +
{ -42.75,  4.5 , 33  , 40  },
 +
{ -42.75,  4.5 ,  4.5, 33  },
 +
{ -90  , -42.78,  4.5, 23  },
 +
white = { -23.3, 35 },
 +
},
 +
}
 +
 +
local function temperatures(frame, inunit, swap)
 +
local palette = palettes[frame.palette] or palettes.cool
 +
return temperature_row(palette, frame.args[1], inunit, swap)
 
end
 
end
  
 
local function CtoF(frame)
 
local function CtoF(frame)
return temperature_row(frame.args[1], 'C')
+
return temperatures(frame, 'C')
 
end
 
end
  
 
local function CfromF(frame)
 
local function CfromF(frame)
return temperature_row(frame.args[1], 'F', true)
+
return temperatures(frame, 'F', true)
 
end
 
end
  
 
local function FtoC(frame)
 
local function FtoC(frame)
return temperature_row(frame.args[1], 'F')
+
return temperatures(frame, 'F')
 
end
 
end
  
 
local function FfromC(frame)
 
local function FfromC(frame)
return temperature_row(frame.args[1], 'C', true)
+
return temperatures(frame, 'C', true)
 +
end
 +
 
 +
local chart = [[
 +
{{Graph:Chart
 +
|width=600
 +
|height=180
 +
|xAxisTitle=Celsius
 +
|yAxisTitle=COLOR
 +
|type=line
 +
|x=XVALUES
 +
|y=YVALUES
 +
|colors=COLOR
 +
}}
 +
]]
 +
 
 +
local function show(frame)
 +
-- For testing, return wikitext to show graphs of how the red/green/blue colors
 +
-- vary with temperature, and a table of the resulting colors.
 +
local function collection()
 +
-- Return a table to hold items.
 +
return {
 +
n = 0,
 +
add = function (self, item)
 +
self.n = self.n + 1
 +
self[self.n] = item
 +
end,
 +
join = function (self, sep)
 +
return table.concat(self, sep)
 +
end,
 +
}
 +
end
 +
local function make_chart(result, color, xvalues, yvalues)
 +
result:add('\n')
 +
local x = xvalues:join(',')
 +
local y = yvalues:join(',')
 +
result:add(frame:preprocess((chart:gsub('COLOR', color):gsub('XVALUES', x):gsub('YVALUES', y))))
 +
end
 +
local palette = palettes[frame.args.palette] or palettes.cool
 +
local data = collection()
 +
local xvals, reds, greens, blues = collection(), collection(), collection(), collection()
 +
local wikitext = collection()
 +
wikitext:add('{| class="wikitable"\n|-\n')
 +
local columns = 0
 +
for celsius = -90, 69 do
 +
local rgb = {}
 +
local style = temperature_style(palette, celsius, rgb)
 +
local R = math.floor(rgb[1])
 +
local G = math.floor(rgb[2])
 +
local B = math.floor(rgb[3])
 +
xvals:add(celsius)
 +
reds:add(R)
 +
greens:add(G)
 +
blues:add(B)
 +
data:add({ celsius, R, G, B })
 +
wikitext:add('| ' .. style .. ' | ' .. celsius .. '\n')
 +
columns = columns + 1
 +
if columns >= 10 then
 +
columns = 0
 +
wikitext:add('|-\n')
 +
end
 +
end
 +
wikitext:add('|}\n')
 +
make_chart(wikitext, 'Red', xvals, reds)
 +
make_chart(wikitext, 'Green', xvals, greens)
 +
make_chart(wikitext, 'Blue', xvals, blues)
 +
return wikitext:join()
 
end
 
end
  
Line 154: Line 238:
 
FtoC = FtoC,
 
FtoC = FtoC,
 
FfromC = FfromC,
 
FfromC = FfromC,
 +
show = show,
 
}
 
}

Revision as of 10:06, 12 September 2016

This module can be used to display temperatures in a table. It is under development and is intended to be efficient so a page can hold many tables.

  • Input numbers must use a hyphen if negative (Unicode minus "−" would give an error).
  • All displayed numbers (including inputs) use Unicode minus if negative.
  • The input consists of 13 values, separated by any number of spaces.
  • Each of the 13 values must be a number. Any invalid value results in the corresponding cell being blank with no error message or tracking category.

The following functions are available:

Function Input Output
CtoF °C °C
(°F)
FfromC °C °F
(°C)
CfromF °F °C
(°F)
FtoC °F °F
(°C)

The following templates use the module:

An example using the above templates and the module is at:

The output can be examined by entering the following example at Special:ExpandTemplates. The output from each of the following lines is identical.

{{#invoke:weather|CtoF|-10 -5 0 5 10 15 20 25 30 35 40 45 50}}
----
{{#invoke:weather|CfromF|14 23 32 41 50 59 68 77 86 95 104 113 122}}

Optional parameter

  • |palette=name
    Where name is the built-in name of a palette:
    cool (default)
    cool2 (modified)
    cool2avg (modified and intended for average temperatures)

Testing

The function show provides a way to test the color schemes. It generates a graph of how the red, green, and blue portions of the color vary with temperature, and a table of the full range of temperatures in °C.

Optional parameters

  • Two unnamed parameters may be entered to specify the first and last Celsius temperatures (|-90|59 by default).
  • The palette can be specified with |palette=name as above.

The following codes produce the same result:

  • {{#invoke:weather|show}}
  • {{#invoke:weather|show|palette=cool}}
-90 -89 -88 -87 -86 -85 -84 -83 -82 -81
-80 -79 -78 -77 -76 -75 -74 -73 -72 -71
-70 -69 -68 -67 -66 -65 -64 -63 -62 -61
-60 -59 -58 -57 -56 -55 -54 -53 -52 -51
-50 -49 -48 -47 -46 -45 -44 -43 -42 -41
-40 -39 -38 -37 -36 -35 -34 -33 -32 -31
-30 -29 -28 -27 -26 -25 -24 -23 -22 -21
-20 -19 -18 -17 -16 -15 -14 -13 -12 -11
-10 -9 -8 -7 -6 -5 -4 -3 -2 -1
0 1 2 3 4 5 6 7 8 9
10 11 12 13 14 15 16 17 18 19
20 21 22 23 24 25 26 27 28 29
30 31 32 33 34 35 36 37 38 39
40 41 42 43 44 45 46 47 48 49
50 51 52 53 54 55 56 57 58 59
60 61 62 63 64 65 66 67 68 69

<graph>{"legends":[],"scales":[{"type":"linear","name":"x","zero":false,"domain":{"data":"chart","field":"x"},"range":"width","nice":true},{"type":"linear","name":"y","domain":{"data":"chart","field":"y"},"zero":false,"range":"height","nice":true},{"domain":{"data":"chart","field":"series"},"type":"ordinal","name":"color","range":["red"]}],"version":2,"marks":[{"type":"line","properties":{"hover":{"stroke":{"value":"red"}},"update":{"stroke":{"scale":"color","field":"series"}},"enter":{"y":{"scale":"y","field":"y"},"x":{"scale":"x","field":"x"},"stroke":{"scale":"color","field":"series"},"strokeWidth":{"value":2.5}}},"from":{"data":"chart"}}],"height":180,"axes":[{"type":"x","title":"Celsius","scale":"x","format":"d","properties":{"title":{"fill":{"value":"#54595d"}},"grid":{"stroke":{"value":"#54595d"}},"ticks":{"stroke":{"value":"#54595d"}},"axis":{"strokeWidth":{"value":2},"stroke":{"value":"#54595d"}},"labels":{"fill":{"value":"#54595d"}}},"grid":false},{"type":"y","title":"Red","scale":"y","format":"d","properties":{"title":{"fill":{"value":"#54595d"}},"grid":{"stroke":{"value":"#54595d"}},"ticks":{"stroke":{"value":"#54595d"}},"axis":{"strokeWidth":{"value":2},"stroke":{"value":"#54595d"}},"labels":{"fill":{"value":"#54595d"}}},"grid":false}],"data":[{"format":{"parse":{"y":"integer","x":"integer"},"type":"json"},"name":"chart","values":[{"y":0,"series":"y","x":-90},{"y":0,"series":"y","x":-89},{"y":0,"series":"y","x":-88},{"y":0,"series":"y","x":-87},{"y":0,"series":"y","x":-86},{"y":0,"series":"y","x":-85},{"y":0,"series":"y","x":-84},{"y":0,"series":"y","x":-83},{"y":0,"series":"y","x":-82},{"y":0,"series":"y","x":-81},{"y":0,"series":"y","x":-80},{"y":0,"series":"y","x":-79},{"y":0,"series":"y","x":-78},{"y":0,"series":"y","x":-77},{"y":0,"series":"y","x":-76},{"y":0,"series":"y","x":-75},{"y":0,"series":"y","x":-74},{"y":0,"series":"y","x":-73},{"y":0,"series":"y","x":-72},{"y":0,"series":"y","x":-71},{"y":0,"series":"y","x":-70},{"y":0,"series":"y","x":-69},{"y":0,"series":"y","x":-68},{"y":0,"series":"y","x":-67},{"y":0,"series":"y","x":-66},{"y":0,"series":"y","x":-65},{"y":0,"series":"y","x":-64},{"y":0,"series":"y","x":-63},{"y":0,"series":"y","x":-62},{"y":0,"series":"y","x":-61},{"y":0,"series":"y","x":-60},{"y":0,"series":"y","x":-59},{"y":0,"series":"y","x":-58},{"y":0,"series":"y","x":-57},{"y":0,"series":"y","x":-56},{"y":0,"series":"y","x":-55},{"y":0,"series":"y","x":-54},{"y":0,"series":"y","x":-53},{"y":0,"series":"y","x":-52},{"y":0,"series":"y","x":-51},{"y":0,"series":"y","x":-50},{"y":0,"series":"y","x":-49},{"y":0,"series":"y","x":-48},{"y":0,"series":"y","x":-47},{"y":0,"series":"y","x":-46},{"y":0,"series":"y","x":-45},{"y":0,"series":"y","x":-44},{"y":0,"series":"y","x":-43},{"y":4,"series":"y","x":-42},{"y":9,"series":"y","x":-41},{"y":14,"series":"y","x":-40},{"y":20,"series":"y","x":-39},{"y":25,"series":"y","x":-38},{"y":31,"series":"y","x":-37},{"y":36,"series":"y","x":-36},{"y":41,"series":"y","x":-35},{"y":47,"series":"y","x":-34},{"y":52,"series":"y","x":-33},{"y":58,"series":"y","x":-32},{"y":63,"series":"y","x":-31},{"y":68,"series":"y","x":-30},{"y":74,"series":"y","x":-29},{"y":79,"series":"y","x":-28},{"y":85,"series":"y","x":-27},{"y":90,"series":"y","x":-26},{"y":95,"series":"y","x":-25},{"y":101,"series":"y","x":-24},{"y":106,"series":"y","x":-23},{"y":112,"series":"y","x":-22},{"y":117,"series":"y","x":-21},{"y":122,"series":"y","x":-20},{"y":128,"series":"y","x":-19},{"y":133,"series":"y","x":-18},{"y":139,"series":"y","x":-17},{"y":144,"series":"y","x":-16},{"y":149,"series":"y","x":-15},{"y":155,"series":"y","x":-14},{"y":160,"series":"y","x":-13},{"y":166,"series":"y","x":-12},{"y":171,"series":"y","x":-11},{"y":176,"series":"y","x":-10},{"y":182,"series":"y","x":-9},{"y":187,"series":"y","x":-8},{"y":193,"series":"y","x":-7},{"y":198,"series":"y","x":-6},{"y":203,"series":"y","x":-5},{"y":209,"series":"y","x":-4},{"y":214,"series":"y","x":-3},{"y":220,"series":"y","x":-2},{"y":225,"series":"y","x":-1},{"y":230,"series":"y","x":0},{"y":236,"series":"y","x":1},{"y":241,"series":"y","x":2},{"y":247,"series":"y","x":3},{"y":252,"series":"y","x":4},{"y":255,"series":"y","x":5},{"y":255,"series":"y","x":6},{"y":255,"series":"y","x":7},{"y":255,"series":"y","x":8},{"y":255,"series":"y","x":9},{"y":255,"series":"y","x":10},{"y":255,"series":"y","x":11},{"y":255,"series":"y","x":12},{"y":255,"series":"y","x":13},{"y":255,"series":"y","x":14},{"y":255,"series":"y","x":15},{"y":255,"series":"y","x":16},{"y":255,"series":"y","x":17},{"y":255,"series":"y","x":18},{"y":255,"series":"y","x":19},{"y":255,"series":"y","x":20},{"y":255,"series":"y","x":21},{"y":255,"series":"y","x":22},{"y":255,"series":"y","x":23},{"y":255,"series":"y","x":24},{"y":255,"series":"y","x":25},{"y":255,"series":"y","x":26},{"y":255,"series":"y","x":27},{"y":255,"series":"y","x":28},{"y":255,"series":"y","x":29},{"y":255,"series":"y","x":30},{"y":255,"series":"y","x":31},{"y":255,"series":"y","x":32},{"y":255,"series":"y","x":33},{"y":255,"series":"y","x":34},{"y":255,"series":"y","x":35},{"y":255,"series":"y","x":36},{"y":255,"series":"y","x":37},{"y":255,"series":"y","x":38},{"y":255,"series":"y","x":39},{"y":255,"series":"y","x":40},{"y":255,"series":"y","x":41},{"y":248,"series":"y","x":42},{"y":234,"series":"y","x":43},{"y":220,"series":"y","x":44},{"y":206,"series":"y","x":45},{"y":192,"series":"y","x":46},{"y":179,"series":"y","x":47},{"y":165,"series":"y","x":48},{"y":151,"series":"y","x":49},{"y":137,"series":"y","x":50},{"y":124,"series":"y","x":51},{"y":110,"series":"y","x":52},{"y":96,"series":"y","x":53},{"y":82,"series":"y","x":54},{"y":68,"series":"y","x":55},{"y":55,"series":"y","x":56},{"y":41,"series":"y","x":57},{"y":27,"series":"y","x":58},{"y":13,"series":"y","x":59},{"y":0,"series":"y","x":60},{"y":0,"series":"y","x":61},{"y":0,"series":"y","x":62},{"y":0,"series":"y","x":63},{"y":0,"series":"y","x":64},{"y":0,"series":"y","x":65},{"y":0,"series":"y","x":66},{"y":0,"series":"y","x":67},{"y":0,"series":"y","x":68},{"y":0,"series":"y","x":69}]}],"width":600}</graph>

<graph>{"legends":[],"scales":[{"type":"linear","name":"x","zero":false,"domain":{"data":"chart","field":"x"},"range":"width","nice":true},{"type":"linear","name":"y","domain":{"data":"chart","field":"y"},"zero":false,"range":"height","nice":true},{"domain":{"data":"chart","field":"series"},"type":"ordinal","name":"color","range":["green"]}],"version":2,"marks":[{"type":"line","properties":{"hover":{"stroke":{"value":"red"}},"update":{"stroke":{"scale":"color","field":"series"}},"enter":{"y":{"scale":"y","field":"y"},"x":{"scale":"x","field":"x"},"stroke":{"scale":"color","field":"series"},"strokeWidth":{"value":2.5}}},"from":{"data":"chart"}}],"height":180,"axes":[{"type":"x","title":"Celsius","scale":"x","format":"d","properties":{"title":{"fill":{"value":"#54595d"}},"grid":{"stroke":{"value":"#54595d"}},"ticks":{"stroke":{"value":"#54595d"}},"axis":{"strokeWidth":{"value":2},"stroke":{"value":"#54595d"}},"labels":{"fill":{"value":"#54595d"}}},"grid":false},{"type":"y","title":"Green","scale":"y","format":"d","properties":{"title":{"fill":{"value":"#54595d"}},"grid":{"stroke":{"value":"#54595d"}},"ticks":{"stroke":{"value":"#54595d"}},"axis":{"strokeWidth":{"value":2},"stroke":{"value":"#54595d"}},"labels":{"fill":{"value":"#54595d"}}},"grid":false}],"data":[{"format":{"parse":{"y":"integer","x":"integer"},"type":"json"},"name":"chart","values":[{"y":0,"series":"y","x":-90},{"y":0,"series":"y","x":-89},{"y":0,"series":"y","x":-88},{"y":0,"series":"y","x":-87},{"y":0,"series":"y","x":-86},{"y":0,"series":"y","x":-85},{"y":0,"series":"y","x":-84},{"y":0,"series":"y","x":-83},{"y":0,"series":"y","x":-82},{"y":0,"series":"y","x":-81},{"y":0,"series":"y","x":-80},{"y":0,"series":"y","x":-79},{"y":0,"series":"y","x":-78},{"y":0,"series":"y","x":-77},{"y":0,"series":"y","x":-76},{"y":0,"series":"y","x":-75},{"y":0,"series":"y","x":-74},{"y":0,"series":"y","x":-73},{"y":0,"series":"y","x":-72},{"y":0,"series":"y","x":-71},{"y":0,"series":"y","x":-70},{"y":0,"series":"y","x":-69},{"y":0,"series":"y","x":-68},{"y":0,"series":"y","x":-67},{"y":0,"series":"y","x":-66},{"y":0,"series":"y","x":-65},{"y":0,"series":"y","x":-64},{"y":0,"series":"y","x":-63},{"y":0,"series":"y","x":-62},{"y":0,"series":"y","x":-61},{"y":0,"series":"y","x":-60},{"y":0,"series":"y","x":-59},{"y":0,"series":"y","x":-58},{"y":0,"series":"y","x":-57},{"y":0,"series":"y","x":-56},{"y":0,"series":"y","x":-55},{"y":0,"series":"y","x":-54},{"y":0,"series":"y","x":-53},{"y":0,"series":"y","x":-52},{"y":0,"series":"y","x":-51},{"y":0,"series":"y","x":-50},{"y":0,"series":"y","x":-49},{"y":0,"series":"y","x":-48},{"y":0,"series":"y","x":-47},{"y":0,"series":"y","x":-46},{"y":0,"series":"y","x":-45},{"y":0,"series":"y","x":-44},{"y":0,"series":"y","x":-43},{"y":4,"series":"y","x":-42},{"y":9,"series":"y","x":-41},{"y":14,"series":"y","x":-40},{"y":20,"series":"y","x":-39},{"y":25,"series":"y","x":-38},{"y":31,"series":"y","x":-37},{"y":36,"series":"y","x":-36},{"y":41,"series":"y","x":-35},{"y":47,"series":"y","x":-34},{"y":52,"series":"y","x":-33},{"y":58,"series":"y","x":-32},{"y":63,"series":"y","x":-31},{"y":68,"series":"y","x":-30},{"y":74,"series":"y","x":-29},{"y":79,"series":"y","x":-28},{"y":85,"series":"y","x":-27},{"y":90,"series":"y","x":-26},{"y":95,"series":"y","x":-25},{"y":101,"series":"y","x":-24},{"y":106,"series":"y","x":-23},{"y":112,"series":"y","x":-22},{"y":117,"series":"y","x":-21},{"y":122,"series":"y","x":-20},{"y":128,"series":"y","x":-19},{"y":133,"series":"y","x":-18},{"y":139,"series":"y","x":-17},{"y":144,"series":"y","x":-16},{"y":149,"series":"y","x":-15},{"y":155,"series":"y","x":-14},{"y":160,"series":"y","x":-13},{"y":166,"series":"y","x":-12},{"y":171,"series":"y","x":-11},{"y":176,"series":"y","x":-10},{"y":182,"series":"y","x":-9},{"y":187,"series":"y","x":-8},{"y":193,"series":"y","x":-7},{"y":198,"series":"y","x":-6},{"y":203,"series":"y","x":-5},{"y":209,"series":"y","x":-4},{"y":214,"series":"y","x":-3},{"y":220,"series":"y","x":-2},{"y":225,"series":"y","x":-1},{"y":230,"series":"y","x":0},{"y":236,"series":"y","x":1},{"y":241,"series":"y","x":2},{"y":247,"series":"y","x":3},{"y":252,"series":"y","x":4},{"y":251,"series":"y","x":5},{"y":244,"series":"y","x":6},{"y":237,"series":"y","x":7},{"y":230,"series":"y","x":8},{"y":223,"series":"y","x":9},{"y":217,"series":"y","x":10},{"y":210,"series":"y","x":11},{"y":203,"series":"y","x":12},{"y":196,"series":"y","x":13},{"y":189,"series":"y","x":14},{"y":182,"series":"y","x":15},{"y":175,"series":"y","x":16},{"y":168,"series":"y","x":17},{"y":161,"series":"y","x":18},{"y":155,"series":"y","x":19},{"y":148,"series":"y","x":20},{"y":141,"series":"y","x":21},{"y":134,"series":"y","x":22},{"y":127,"series":"y","x":23},{"y":120,"series":"y","x":24},{"y":113,"series":"y","x":25},{"y":106,"series":"y","x":26},{"y":99,"series":"y","x":27},{"y":93,"series":"y","x":28},{"y":86,"series":"y","x":29},{"y":79,"series":"y","x":30},{"y":72,"series":"y","x":31},{"y":65,"series":"y","x":32},{"y":58,"series":"y","x":33},{"y":51,"series":"y","x":34},{"y":44,"series":"y","x":35},{"y":37,"series":"y","x":36},{"y":31,"series":"y","x":37},{"y":24,"series":"y","x":38},{"y":17,"series":"y","x":39},{"y":10,"series":"y","x":40},{"y":3,"series":"y","x":41},{"y":0,"series":"y","x":42},{"y":0,"series":"y","x":43},{"y":0,"series":"y","x":44},{"y":0,"series":"y","x":45},{"y":0,"series":"y","x":46},{"y":0,"series":"y","x":47},{"y":0,"series":"y","x":48},{"y":0,"series":"y","x":49},{"y":0,"series":"y","x":50},{"y":0,"series":"y","x":51},{"y":0,"series":"y","x":52},{"y":0,"series":"y","x":53},{"y":0,"series":"y","x":54},{"y":0,"series":"y","x":55},{"y":0,"series":"y","x":56},{"y":0,"series":"y","x":57},{"y":0,"series":"y","x":58},{"y":0,"series":"y","x":59},{"y":0,"series":"y","x":60},{"y":0,"series":"y","x":61},{"y":0,"series":"y","x":62},{"y":0,"series":"y","x":63},{"y":0,"series":"y","x":64},{"y":0,"series":"y","x":65},{"y":0,"series":"y","x":66},{"y":0,"series":"y","x":67},{"y":0,"series":"y","x":68},{"y":0,"series":"y","x":69}]}],"width":600}</graph>

<graph>{"legends":[],"scales":[{"type":"linear","name":"x","zero":false,"domain":{"data":"chart","field":"x"},"range":"width","nice":true},{"type":"linear","name":"y","domain":{"data":"chart","field":"y"},"zero":false,"range":"height","nice":true},{"domain":{"data":"chart","field":"series"},"type":"ordinal","name":"color","range":["blue"]}],"version":2,"marks":[{"type":"line","properties":{"hover":{"stroke":{"value":"red"}},"update":{"stroke":{"scale":"color","field":"series"}},"enter":{"y":{"scale":"y","field":"y"},"x":{"scale":"x","field":"x"},"stroke":{"scale":"color","field":"series"},"strokeWidth":{"value":2.5}}},"from":{"data":"chart"}}],"height":180,"axes":[{"type":"x","title":"Celsius","scale":"x","format":"d","properties":{"title":{"fill":{"value":"#54595d"}},"grid":{"stroke":{"value":"#54595d"}},"ticks":{"stroke":{"value":"#54595d"}},"axis":{"strokeWidth":{"value":2},"stroke":{"value":"#54595d"}},"labels":{"fill":{"value":"#54595d"}}},"grid":false},{"type":"y","title":"Blue","scale":"y","format":"d","properties":{"title":{"fill":{"value":"#54595d"}},"grid":{"stroke":{"value":"#54595d"}},"ticks":{"stroke":{"value":"#54595d"}},"axis":{"strokeWidth":{"value":2},"stroke":{"value":"#54595d"}},"labels":{"fill":{"value":"#54595d"}}},"grid":false}],"data":[{"format":{"parse":{"y":"integer","x":"integer"},"type":"json"},"name":"chart","values":[{"y":0,"series":"y","x":-90},{"y":5,"series":"y","x":-89},{"y":10,"series":"y","x":-88},{"y":16,"series":"y","x":-87},{"y":21,"series":"y","x":-86},{"y":27,"series":"y","x":-85},{"y":32,"series":"y","x":-84},{"y":37,"series":"y","x":-83},{"y":43,"series":"y","x":-82},{"y":48,"series":"y","x":-81},{"y":54,"series":"y","x":-80},{"y":59,"series":"y","x":-79},{"y":64,"series":"y","x":-78},{"y":70,"series":"y","x":-77},{"y":75,"series":"y","x":-76},{"y":81,"series":"y","x":-75},{"y":86,"series":"y","x":-74},{"y":91,"series":"y","x":-73},{"y":97,"series":"y","x":-72},{"y":102,"series":"y","x":-71},{"y":108,"series":"y","x":-70},{"y":113,"series":"y","x":-69},{"y":118,"series":"y","x":-68},{"y":124,"series":"y","x":-67},{"y":129,"series":"y","x":-66},{"y":135,"series":"y","x":-65},{"y":140,"series":"y","x":-64},{"y":145,"series":"y","x":-63},{"y":151,"series":"y","x":-62},{"y":156,"series":"y","x":-61},{"y":162,"series":"y","x":-60},{"y":167,"series":"y","x":-59},{"y":172,"series":"y","x":-58},{"y":178,"series":"y","x":-57},{"y":183,"series":"y","x":-56},{"y":189,"series":"y","x":-55},{"y":194,"series":"y","x":-54},{"y":199,"series":"y","x":-53},{"y":205,"series":"y","x":-52},{"y":210,"series":"y","x":-51},{"y":216,"series":"y","x":-50},{"y":221,"series":"y","x":-49},{"y":226,"series":"y","x":-48},{"y":232,"series":"y","x":-47},{"y":237,"series":"y","x":-46},{"y":243,"series":"y","x":-45},{"y":248,"series":"y","x":-44},{"y":253,"series":"y","x":-43},{"y":255,"series":"y","x":-42},{"y":255,"series":"y","x":-41},{"y":255,"series":"y","x":-40},{"y":255,"series":"y","x":-39},{"y":255,"series":"y","x":-38},{"y":255,"series":"y","x":-37},{"y":255,"series":"y","x":-36},{"y":255,"series":"y","x":-35},{"y":255,"series":"y","x":-34},{"y":255,"series":"y","x":-33},{"y":255,"series":"y","x":-32},{"y":255,"series":"y","x":-31},{"y":255,"series":"y","x":-30},{"y":255,"series":"y","x":-29},{"y":255,"series":"y","x":-28},{"y":255,"series":"y","x":-27},{"y":255,"series":"y","x":-26},{"y":255,"series":"y","x":-25},{"y":255,"series":"y","x":-24},{"y":255,"series":"y","x":-23},{"y":255,"series":"y","x":-22},{"y":255,"series":"y","x":-21},{"y":255,"series":"y","x":-20},{"y":255,"series":"y","x":-19},{"y":255,"series":"y","x":-18},{"y":255,"series":"y","x":-17},{"y":255,"series":"y","x":-16},{"y":255,"series":"y","x":-15},{"y":255,"series":"y","x":-14},{"y":255,"series":"y","x":-13},{"y":255,"series":"y","x":-12},{"y":255,"series":"y","x":-11},{"y":255,"series":"y","x":-10},{"y":255,"series":"y","x":-9},{"y":255,"series":"y","x":-8},{"y":255,"series":"y","x":-7},{"y":255,"series":"y","x":-6},{"y":255,"series":"y","x":-5},{"y":255,"series":"y","x":-4},{"y":255,"series":"y","x":-3},{"y":255,"series":"y","x":-2},{"y":255,"series":"y","x":-1},{"y":255,"series":"y","x":0},{"y":255,"series":"y","x":1},{"y":255,"series":"y","x":2},{"y":255,"series":"y","x":3},{"y":255,"series":"y","x":4},{"y":248,"series":"y","x":5},{"y":234,"series":"y","x":6},{"y":220,"series":"y","x":7},{"y":206,"series":"y","x":8},{"y":192,"series":"y","x":9},{"y":179,"series":"y","x":10},{"y":165,"series":"y","x":11},{"y":151,"series":"y","x":12},{"y":137,"series":"y","x":13},{"y":124,"series":"y","x":14},{"y":110,"series":"y","x":15},{"y":96,"series":"y","x":16},{"y":82,"series":"y","x":17},{"y":68,"series":"y","x":18},{"y":55,"series":"y","x":19},{"y":41,"series":"y","x":20},{"y":27,"series":"y","x":21},{"y":13,"series":"y","x":22},{"y":0,"series":"y","x":23},{"y":0,"series":"y","x":24},{"y":0,"series":"y","x":25},{"y":0,"series":"y","x":26},{"y":0,"series":"y","x":27},{"y":0,"series":"y","x":28},{"y":0,"series":"y","x":29},{"y":0,"series":"y","x":30},{"y":0,"series":"y","x":31},{"y":0,"series":"y","x":32},{"y":0,"series":"y","x":33},{"y":0,"series":"y","x":34},{"y":0,"series":"y","x":35},{"y":0,"series":"y","x":36},{"y":0,"series":"y","x":37},{"y":0,"series":"y","x":38},{"y":0,"series":"y","x":39},{"y":0,"series":"y","x":40},{"y":0,"series":"y","x":41},{"y":0,"series":"y","x":42},{"y":0,"series":"y","x":43},{"y":0,"series":"y","x":44},{"y":0,"series":"y","x":45},{"y":0,"series":"y","x":46},{"y":0,"series":"y","x":47},{"y":0,"series":"y","x":48},{"y":0,"series":"y","x":49},{"y":0,"series":"y","x":50},{"y":0,"series":"y","x":51},{"y":0,"series":"y","x":52},{"y":0,"series":"y","x":53},{"y":0,"series":"y","x":54},{"y":0,"series":"y","x":55},{"y":0,"series":"y","x":56},{"y":0,"series":"y","x":57},{"y":0,"series":"y","x":58},{"y":0,"series":"y","x":59},{"y":0,"series":"y","x":60},{"y":0,"series":"y","x":61},{"y":0,"series":"y","x":62},{"y":0,"series":"y","x":63},{"y":0,"series":"y","x":64},{"y":0,"series":"y","x":65},{"y":0,"series":"y","x":66},{"y":0,"series":"y","x":67},{"y":0,"series":"y","x":68},{"y":0,"series":"y","x":69}]}],"width":600}</graph>


Modified palette:

  • {{#invoke:weather|show|palette=cool2}}


-90 -89 -88 -87 -86 -85 -84 -83 -82 -81
-80 -79 -78 -77 -76 -75 -74 -73 -72 -71
-70 -69 -68 -67 -66 -65 -64 -63 -62 -61
-60 -59 -58 -57 -56 -55 -54 -53 -52 -51
-50 -49 -48 -47 -46 -45 -44 -43 -42 -41
-40 -39 -38 -37 -36 -35 -34 -33 -32 -31
-30 -29 -28 -27 -26 -25 -24 -23 -22 -21
-20 -19 -18 -17 -16 -15 -14 -13 -12 -11
-10 -9 -8 -7 -6 -5 -4 -3 -2 -1
0 1 2 3 4 5 6 7 8 9
10 11 12 13 14 15 16 17 18 19
20 21 22 23 24 25 26 27 28 29
30 31 32 33 34 35 36 37 38 39
40 41 42 43 44 45 46 47 48 49
50 51 52 53 54 55 56 57 58 59
60 61 62 63 64 65 66 67 68 69

<graph>{"legends":[],"scales":[{"type":"linear","name":"x","zero":false,"domain":{"data":"chart","field":"x"},"range":"width","nice":true},{"type":"linear","name":"y","domain":{"data":"chart","field":"y"},"zero":false,"range":"height","nice":true},{"domain":{"data":"chart","field":"series"},"type":"ordinal","name":"color","range":["red"]}],"version":2,"marks":[{"type":"line","properties":{"hover":{"stroke":{"value":"red"}},"update":{"stroke":{"scale":"color","field":"series"}},"enter":{"y":{"scale":"y","field":"y"},"x":{"scale":"x","field":"x"},"stroke":{"scale":"color","field":"series"},"strokeWidth":{"value":2.5}}},"from":{"data":"chart"}}],"height":180,"axes":[{"type":"x","title":"Celsius","scale":"x","format":"d","properties":{"title":{"fill":{"value":"#54595d"}},"grid":{"stroke":{"value":"#54595d"}},"ticks":{"stroke":{"value":"#54595d"}},"axis":{"strokeWidth":{"value":2},"stroke":{"value":"#54595d"}},"labels":{"fill":{"value":"#54595d"}}},"grid":false},{"type":"y","title":"Red","scale":"y","format":"d","properties":{"title":{"fill":{"value":"#54595d"}},"grid":{"stroke":{"value":"#54595d"}},"ticks":{"stroke":{"value":"#54595d"}},"axis":{"strokeWidth":{"value":2},"stroke":{"value":"#54595d"}},"labels":{"fill":{"value":"#54595d"}}},"grid":false}],"data":[{"format":{"parse":{"y":"integer","x":"integer"},"type":"json"},"name":"chart","values":[{"y":0,"series":"y","x":-90},{"y":0,"series":"y","x":-89},{"y":0,"series":"y","x":-88},{"y":0,"series":"y","x":-87},{"y":0,"series":"y","x":-86},{"y":0,"series":"y","x":-85},{"y":0,"series":"y","x":-84},{"y":0,"series":"y","x":-83},{"y":0,"series":"y","x":-82},{"y":0,"series":"y","x":-81},{"y":0,"series":"y","x":-80},{"y":0,"series":"y","x":-79},{"y":0,"series":"y","x":-78},{"y":0,"series":"y","x":-77},{"y":0,"series":"y","x":-76},{"y":0,"series":"y","x":-75},{"y":0,"series":"y","x":-74},{"y":0,"series":"y","x":-73},{"y":0,"series":"y","x":-72},{"y":0,"series":"y","x":-71},{"y":0,"series":"y","x":-70},{"y":0,"series":"y","x":-69},{"y":0,"series":"y","x":-68},{"y":0,"series":"y","x":-67},{"y":0,"series":"y","x":-66},{"y":0,"series":"y","x":-65},{"y":0,"series":"y","x":-64},{"y":0,"series":"y","x":-63},{"y":0,"series":"y","x":-62},{"y":0,"series":"y","x":-61},{"y":0,"series":"y","x":-60},{"y":0,"series":"y","x":-59},{"y":0,"series":"y","x":-58},{"y":0,"series":"y","x":-57},{"y":0,"series":"y","x":-56},{"y":0,"series":"y","x":-55},{"y":0,"series":"y","x":-54},{"y":0,"series":"y","x":-53},{"y":0,"series":"y","x":-52},{"y":0,"series":"y","x":-51},{"y":0,"series":"y","x":-50},{"y":0,"series":"y","x":-49},{"y":0,"series":"y","x":-48},{"y":0,"series":"y","x":-47},{"y":0,"series":"y","x":-46},{"y":0,"series":"y","x":-45},{"y":0,"series":"y","x":-44},{"y":0,"series":"y","x":-43},{"y":4,"series":"y","x":-42},{"y":9,"series":"y","x":-41},{"y":14,"series":"y","x":-40},{"y":20,"series":"y","x":-39},{"y":25,"series":"y","x":-38},{"y":31,"series":"y","x":-37},{"y":36,"series":"y","x":-36},{"y":41,"series":"y","x":-35},{"y":47,"series":"y","x":-34},{"y":52,"series":"y","x":-33},{"y":58,"series":"y","x":-32},{"y":63,"series":"y","x":-31},{"y":68,"series":"y","x":-30},{"y":74,"series":"y","x":-29},{"y":79,"series":"y","x":-28},{"y":85,"series":"y","x":-27},{"y":90,"series":"y","x":-26},{"y":95,"series":"y","x":-25},{"y":101,"series":"y","x":-24},{"y":106,"series":"y","x":-23},{"y":111,"series":"y","x":-22},{"y":117,"series":"y","x":-21},{"y":122,"series":"y","x":-20},{"y":128,"series":"y","x":-19},{"y":133,"series":"y","x":-18},{"y":138,"series":"y","x":-17},{"y":144,"series":"y","x":-16},{"y":149,"series":"y","x":-15},{"y":155,"series":"y","x":-14},{"y":160,"series":"y","x":-13},{"y":165,"series":"y","x":-12},{"y":171,"series":"y","x":-11},{"y":176,"series":"y","x":-10},{"y":182,"series":"y","x":-9},{"y":187,"series":"y","x":-8},{"y":192,"series":"y","x":-7},{"y":198,"series":"y","x":-6},{"y":203,"series":"y","x":-5},{"y":209,"series":"y","x":-4},{"y":214,"series":"y","x":-3},{"y":219,"series":"y","x":-2},{"y":225,"series":"y","x":-1},{"y":230,"series":"y","x":0},{"y":236,"series":"y","x":1},{"y":241,"series":"y","x":2},{"y":246,"series":"y","x":3},{"y":252,"series":"y","x":4},{"y":255,"series":"y","x":5},{"y":255,"series":"y","x":6},{"y":255,"series":"y","x":7},{"y":255,"series":"y","x":8},{"y":255,"series":"y","x":9},{"y":255,"series":"y","x":10},{"y":255,"series":"y","x":11},{"y":255,"series":"y","x":12},{"y":255,"series":"y","x":13},{"y":255,"series":"y","x":14},{"y":255,"series":"y","x":15},{"y":255,"series":"y","x":16},{"y":255,"series":"y","x":17},{"y":255,"series":"y","x":18},{"y":255,"series":"y","x":19},{"y":255,"series":"y","x":20},{"y":255,"series":"y","x":21},{"y":255,"series":"y","x":22},{"y":255,"series":"y","x":23},{"y":255,"series":"y","x":24},{"y":255,"series":"y","x":25},{"y":255,"series":"y","x":26},{"y":255,"series":"y","x":27},{"y":255,"series":"y","x":28},{"y":255,"series":"y","x":29},{"y":255,"series":"y","x":30},{"y":255,"series":"y","x":31},{"y":255,"series":"y","x":32},{"y":255,"series":"y","x":33},{"y":255,"series":"y","x":34},{"y":255,"series":"y","x":35},{"y":255,"series":"y","x":36},{"y":255,"series":"y","x":37},{"y":255,"series":"y","x":38},{"y":255,"series":"y","x":39},{"y":255,"series":"y","x":40},{"y":255,"series":"y","x":41},{"y":246,"series":"y","x":42},{"y":228,"series":"y","x":43},{"y":211,"series":"y","x":44},{"y":193,"series":"y","x":45},{"y":175,"series":"y","x":46},{"y":158,"series":"y","x":47},{"y":140,"series":"y","x":48},{"y":123,"series":"y","x":49},{"y":105,"series":"y","x":50},{"y":87,"series":"y","x":51},{"y":70,"series":"y","x":52},{"y":52,"series":"y","x":53},{"y":35,"series":"y","x":54},{"y":17,"series":"y","x":55},{"y":0,"series":"y","x":56},{"y":0,"series":"y","x":57},{"y":0,"series":"y","x":58},{"y":0,"series":"y","x":59},{"y":0,"series":"y","x":60},{"y":0,"series":"y","x":61},{"y":0,"series":"y","x":62},{"y":0,"series":"y","x":63},{"y":0,"series":"y","x":64},{"y":0,"series":"y","x":65},{"y":0,"series":"y","x":66},{"y":0,"series":"y","x":67},{"y":0,"series":"y","x":68},{"y":0,"series":"y","x":69}]}],"width":600}</graph>

<graph>{"legends":[],"scales":[{"type":"linear","name":"x","zero":false,"domain":{"data":"chart","field":"x"},"range":"width","nice":true},{"type":"linear","name":"y","domain":{"data":"chart","field":"y"},"zero":false,"range":"height","nice":true},{"domain":{"data":"chart","field":"series"},"type":"ordinal","name":"color","range":["green"]}],"version":2,"marks":[{"type":"line","properties":{"hover":{"stroke":{"value":"red"}},"update":{"stroke":{"scale":"color","field":"series"}},"enter":{"y":{"scale":"y","field":"y"},"x":{"scale":"x","field":"x"},"stroke":{"scale":"color","field":"series"},"strokeWidth":{"value":2.5}}},"from":{"data":"chart"}}],"height":180,"axes":[{"type":"x","title":"Celsius","scale":"x","format":"d","properties":{"title":{"fill":{"value":"#54595d"}},"grid":{"stroke":{"value":"#54595d"}},"ticks":{"stroke":{"value":"#54595d"}},"axis":{"strokeWidth":{"value":2},"stroke":{"value":"#54595d"}},"labels":{"fill":{"value":"#54595d"}}},"grid":false},{"type":"y","title":"Green","scale":"y","format":"d","properties":{"title":{"fill":{"value":"#54595d"}},"grid":{"stroke":{"value":"#54595d"}},"ticks":{"stroke":{"value":"#54595d"}},"axis":{"strokeWidth":{"value":2},"stroke":{"value":"#54595d"}},"labels":{"fill":{"value":"#54595d"}}},"grid":false}],"data":[{"format":{"parse":{"y":"integer","x":"integer"},"type":"json"},"name":"chart","values":[{"y":0,"series":"y","x":-90},{"y":0,"series":"y","x":-89},{"y":0,"series":"y","x":-88},{"y":0,"series":"y","x":-87},{"y":0,"series":"y","x":-86},{"y":0,"series":"y","x":-85},{"y":0,"series":"y","x":-84},{"y":0,"series":"y","x":-83},{"y":0,"series":"y","x":-82},{"y":0,"series":"y","x":-81},{"y":0,"series":"y","x":-80},{"y":0,"series":"y","x":-79},{"y":0,"series":"y","x":-78},{"y":0,"series":"y","x":-77},{"y":0,"series":"y","x":-76},{"y":0,"series":"y","x":-75},{"y":0,"series":"y","x":-74},{"y":0,"series":"y","x":-73},{"y":0,"series":"y","x":-72},{"y":0,"series":"y","x":-71},{"y":0,"series":"y","x":-70},{"y":0,"series":"y","x":-69},{"y":0,"series":"y","x":-68},{"y":0,"series":"y","x":-67},{"y":0,"series":"y","x":-66},{"y":0,"series":"y","x":-65},{"y":0,"series":"y","x":-64},{"y":0,"series":"y","x":-63},{"y":0,"series":"y","x":-62},{"y":0,"series":"y","x":-61},{"y":0,"series":"y","x":-60},{"y":0,"series":"y","x":-59},{"y":0,"series":"y","x":-58},{"y":0,"series":"y","x":-57},{"y":0,"series":"y","x":-56},{"y":0,"series":"y","x":-55},{"y":0,"series":"y","x":-54},{"y":0,"series":"y","x":-53},{"y":0,"series":"y","x":-52},{"y":0,"series":"y","x":-51},{"y":0,"series":"y","x":-50},{"y":0,"series":"y","x":-49},{"y":0,"series":"y","x":-48},{"y":0,"series":"y","x":-47},{"y":0,"series":"y","x":-46},{"y":0,"series":"y","x":-45},{"y":0,"series":"y","x":-44},{"y":0,"series":"y","x":-43},{"y":4,"series":"y","x":-42},{"y":9,"series":"y","x":-41},{"y":14,"series":"y","x":-40},{"y":20,"series":"y","x":-39},{"y":25,"series":"y","x":-38},{"y":31,"series":"y","x":-37},{"y":36,"series":"y","x":-36},{"y":41,"series":"y","x":-35},{"y":47,"series":"y","x":-34},{"y":52,"series":"y","x":-33},{"y":58,"series":"y","x":-32},{"y":63,"series":"y","x":-31},{"y":68,"series":"y","x":-30},{"y":74,"series":"y","x":-29},{"y":79,"series":"y","x":-28},{"y":85,"series":"y","x":-27},{"y":90,"series":"y","x":-26},{"y":95,"series":"y","x":-25},{"y":101,"series":"y","x":-24},{"y":106,"series":"y","x":-23},{"y":111,"series":"y","x":-22},{"y":117,"series":"y","x":-21},{"y":122,"series":"y","x":-20},{"y":128,"series":"y","x":-19},{"y":133,"series":"y","x":-18},{"y":138,"series":"y","x":-17},{"y":144,"series":"y","x":-16},{"y":149,"series":"y","x":-15},{"y":155,"series":"y","x":-14},{"y":160,"series":"y","x":-13},{"y":165,"series":"y","x":-12},{"y":171,"series":"y","x":-11},{"y":176,"series":"y","x":-10},{"y":182,"series":"y","x":-9},{"y":187,"series":"y","x":-8},{"y":192,"series":"y","x":-7},{"y":198,"series":"y","x":-6},{"y":203,"series":"y","x":-5},{"y":209,"series":"y","x":-4},{"y":214,"series":"y","x":-3},{"y":219,"series":"y","x":-2},{"y":225,"series":"y","x":-1},{"y":230,"series":"y","x":0},{"y":236,"series":"y","x":1},{"y":241,"series":"y","x":2},{"y":246,"series":"y","x":3},{"y":252,"series":"y","x":4},{"y":251,"series":"y","x":5},{"y":244,"series":"y","x":6},{"y":237,"series":"y","x":7},{"y":230,"series":"y","x":8},{"y":223,"series":"y","x":9},{"y":217,"series":"y","x":10},{"y":210,"series":"y","x":11},{"y":203,"series":"y","x":12},{"y":196,"series":"y","x":13},{"y":189,"series":"y","x":14},{"y":182,"series":"y","x":15},{"y":175,"series":"y","x":16},{"y":168,"series":"y","x":17},{"y":161,"series":"y","x":18},{"y":155,"series":"y","x":19},{"y":148,"series":"y","x":20},{"y":141,"series":"y","x":21},{"y":134,"series":"y","x":22},{"y":127,"series":"y","x":23},{"y":120,"series":"y","x":24},{"y":113,"series":"y","x":25},{"y":106,"series":"y","x":26},{"y":99,"series":"y","x":27},{"y":93,"series":"y","x":28},{"y":86,"series":"y","x":29},{"y":79,"series":"y","x":30},{"y":72,"series":"y","x":31},{"y":65,"series":"y","x":32},{"y":58,"series":"y","x":33},{"y":51,"series":"y","x":34},{"y":44,"series":"y","x":35},{"y":37,"series":"y","x":36},{"y":31,"series":"y","x":37},{"y":24,"series":"y","x":38},{"y":17,"series":"y","x":39},{"y":10,"series":"y","x":40},{"y":3,"series":"y","x":41},{"y":0,"series":"y","x":42},{"y":0,"series":"y","x":43},{"y":0,"series":"y","x":44},{"y":0,"series":"y","x":45},{"y":0,"series":"y","x":46},{"y":0,"series":"y","x":47},{"y":0,"series":"y","x":48},{"y":0,"series":"y","x":49},{"y":0,"series":"y","x":50},{"y":0,"series":"y","x":51},{"y":0,"series":"y","x":52},{"y":0,"series":"y","x":53},{"y":0,"series":"y","x":54},{"y":0,"series":"y","x":55},{"y":0,"series":"y","x":56},{"y":0,"series":"y","x":57},{"y":0,"series":"y","x":58},{"y":0,"series":"y","x":59},{"y":0,"series":"y","x":60},{"y":0,"series":"y","x":61},{"y":0,"series":"y","x":62},{"y":0,"series":"y","x":63},{"y":0,"series":"y","x":64},{"y":0,"series":"y","x":65},{"y":0,"series":"y","x":66},{"y":0,"series":"y","x":67},{"y":0,"series":"y","x":68},{"y":0,"series":"y","x":69}]}],"width":600}</graph>

<graph>{"legends":[],"scales":[{"type":"linear","name":"x","zero":false,"domain":{"data":"chart","field":"x"},"range":"width","nice":true},{"type":"linear","name":"y","domain":{"data":"chart","field":"y"},"zero":false,"range":"height","nice":true},{"domain":{"data":"chart","field":"series"},"type":"ordinal","name":"color","range":["blue"]}],"version":2,"marks":[{"type":"line","properties":{"hover":{"stroke":{"value":"red"}},"update":{"stroke":{"scale":"color","field":"series"}},"enter":{"y":{"scale":"y","field":"y"},"x":{"scale":"x","field":"x"},"stroke":{"scale":"color","field":"series"},"strokeWidth":{"value":2.5}}},"from":{"data":"chart"}}],"height":180,"axes":[{"type":"x","title":"Celsius","scale":"x","format":"d","properties":{"title":{"fill":{"value":"#54595d"}},"grid":{"stroke":{"value":"#54595d"}},"ticks":{"stroke":{"value":"#54595d"}},"axis":{"strokeWidth":{"value":2},"stroke":{"value":"#54595d"}},"labels":{"fill":{"value":"#54595d"}}},"grid":false},{"type":"y","title":"Blue","scale":"y","format":"d","properties":{"title":{"fill":{"value":"#54595d"}},"grid":{"stroke":{"value":"#54595d"}},"ticks":{"stroke":{"value":"#54595d"}},"axis":{"strokeWidth":{"value":2},"stroke":{"value":"#54595d"}},"labels":{"fill":{"value":"#54595d"}}},"grid":false}],"data":[{"format":{"parse":{"y":"integer","x":"integer"},"type":"json"},"name":"chart","values":[{"y":0,"series":"y","x":-90},{"y":5,"series":"y","x":-89},{"y":10,"series":"y","x":-88},{"y":16,"series":"y","x":-87},{"y":21,"series":"y","x":-86},{"y":27,"series":"y","x":-85},{"y":32,"series":"y","x":-84},{"y":37,"series":"y","x":-83},{"y":43,"series":"y","x":-82},{"y":48,"series":"y","x":-81},{"y":54,"series":"y","x":-80},{"y":59,"series":"y","x":-79},{"y":64,"series":"y","x":-78},{"y":70,"series":"y","x":-77},{"y":75,"series":"y","x":-76},{"y":81,"series":"y","x":-75},{"y":86,"series":"y","x":-74},{"y":91,"series":"y","x":-73},{"y":97,"series":"y","x":-72},{"y":102,"series":"y","x":-71},{"y":108,"series":"y","x":-70},{"y":113,"series":"y","x":-69},{"y":118,"series":"y","x":-68},{"y":124,"series":"y","x":-67},{"y":129,"series":"y","x":-66},{"y":135,"series":"y","x":-65},{"y":140,"series":"y","x":-64},{"y":145,"series":"y","x":-63},{"y":151,"series":"y","x":-62},{"y":156,"series":"y","x":-61},{"y":162,"series":"y","x":-60},{"y":167,"series":"y","x":-59},{"y":172,"series":"y","x":-58},{"y":178,"series":"y","x":-57},{"y":183,"series":"y","x":-56},{"y":189,"series":"y","x":-55},{"y":194,"series":"y","x":-54},{"y":199,"series":"y","x":-53},{"y":205,"series":"y","x":-52},{"y":210,"series":"y","x":-51},{"y":216,"series":"y","x":-50},{"y":221,"series":"y","x":-49},{"y":226,"series":"y","x":-48},{"y":232,"series":"y","x":-47},{"y":237,"series":"y","x":-46},{"y":243,"series":"y","x":-45},{"y":248,"series":"y","x":-44},{"y":253,"series":"y","x":-43},{"y":255,"series":"y","x":-42},{"y":255,"series":"y","x":-41},{"y":255,"series":"y","x":-40},{"y":255,"series":"y","x":-39},{"y":255,"series":"y","x":-38},{"y":255,"series":"y","x":-37},{"y":255,"series":"y","x":-36},{"y":255,"series":"y","x":-35},{"y":255,"series":"y","x":-34},{"y":255,"series":"y","x":-33},{"y":255,"series":"y","x":-32},{"y":255,"series":"y","x":-31},{"y":255,"series":"y","x":-30},{"y":255,"series":"y","x":-29},{"y":255,"series":"y","x":-28},{"y":255,"series":"y","x":-27},{"y":255,"series":"y","x":-26},{"y":255,"series":"y","x":-25},{"y":255,"series":"y","x":-24},{"y":255,"series":"y","x":-23},{"y":255,"series":"y","x":-22},{"y":255,"series":"y","x":-21},{"y":255,"series":"y","x":-20},{"y":255,"series":"y","x":-19},{"y":255,"series":"y","x":-18},{"y":255,"series":"y","x":-17},{"y":255,"series":"y","x":-16},{"y":255,"series":"y","x":-15},{"y":255,"series":"y","x":-14},{"y":255,"series":"y","x":-13},{"y":255,"series":"y","x":-12},{"y":255,"series":"y","x":-11},{"y":255,"series":"y","x":-10},{"y":255,"series":"y","x":-9},{"y":255,"series":"y","x":-8},{"y":255,"series":"y","x":-7},{"y":255,"series":"y","x":-6},{"y":255,"series":"y","x":-5},{"y":255,"series":"y","x":-4},{"y":255,"series":"y","x":-3},{"y":255,"series":"y","x":-2},{"y":255,"series":"y","x":-1},{"y":255,"series":"y","x":0},{"y":255,"series":"y","x":1},{"y":255,"series":"y","x":2},{"y":255,"series":"y","x":3},{"y":255,"series":"y","x":4},{"y":248,"series":"y","x":5},{"y":234,"series":"y","x":6},{"y":220,"series":"y","x":7},{"y":206,"series":"y","x":8},{"y":192,"series":"y","x":9},{"y":179,"series":"y","x":10},{"y":165,"series":"y","x":11},{"y":151,"series":"y","x":12},{"y":137,"series":"y","x":13},{"y":124,"series":"y","x":14},{"y":110,"series":"y","x":15},{"y":96,"series":"y","x":16},{"y":82,"series":"y","x":17},{"y":68,"series":"y","x":18},{"y":55,"series":"y","x":19},{"y":41,"series":"y","x":20},{"y":27,"series":"y","x":21},{"y":13,"series":"y","x":22},{"y":0,"series":"y","x":23},{"y":0,"series":"y","x":24},{"y":0,"series":"y","x":25},{"y":0,"series":"y","x":26},{"y":0,"series":"y","x":27},{"y":0,"series":"y","x":28},{"y":0,"series":"y","x":29},{"y":0,"series":"y","x":30},{"y":0,"series":"y","x":31},{"y":0,"series":"y","x":32},{"y":0,"series":"y","x":33},{"y":0,"series":"y","x":34},{"y":0,"series":"y","x":35},{"y":0,"series":"y","x":36},{"y":0,"series":"y","x":37},{"y":0,"series":"y","x":38},{"y":0,"series":"y","x":39},{"y":0,"series":"y","x":40},{"y":0,"series":"y","x":41},{"y":0,"series":"y","x":42},{"y":0,"series":"y","x":43},{"y":0,"series":"y","x":44},{"y":0,"series":"y","x":45},{"y":0,"series":"y","x":46},{"y":0,"series":"y","x":47},{"y":0,"series":"y","x":48},{"y":0,"series":"y","x":49},{"y":0,"series":"y","x":50},{"y":0,"series":"y","x":51},{"y":0,"series":"y","x":52},{"y":0,"series":"y","x":53},{"y":0,"series":"y","x":54},{"y":0,"series":"y","x":55},{"y":0,"series":"y","x":56},{"y":0,"series":"y","x":57},{"y":0,"series":"y","x":58},{"y":0,"series":"y","x":59},{"y":0,"series":"y","x":60},{"y":0,"series":"y","x":61},{"y":0,"series":"y","x":62},{"y":0,"series":"y","x":63},{"y":0,"series":"y","x":64},{"y":0,"series":"y","x":65},{"y":0,"series":"y","x":66},{"y":0,"series":"y","x":67},{"y":0,"series":"y","x":68},{"y":0,"series":"y","x":69}]}],"width":600}</graph>


This modified palette is intended for average temperatures. It results in good colors between the extreme highest average monthly temperature of +39 °C (102 °F) in Death Valley, California, and −68 °C (−90 °F), the extreme lowest average monthly temperature at Vostok Station, at a high elevation on the Antarctic ice sheet. These are the highest and lowest known average temperatures recorded on Earth, not to be confused with the highest and lowest records, which are quite a bit hotter and colder.


  • {{#invoke:weather|show|palette=cool2avg}}
-90 -89 -88 -87 -86 -85 -84 -83 -82 -81
-80 -79 -78 -77 -76 -75 -74 -73 -72 -71
-70 -69 -68 -67 -66 -65 -64 -63 -62 -61
-60 -59 -58 -57 -56 -55 -54 -53 -52 -51
-50 -49 -48 -47 -46 -45 -44 -43 -42 -41
-40 -39 -38 -37 -36 -35 -34 -33 -32 -31
-30 -29 -28 -27 -26 -25 -24 -23 -22 -21
-20 -19 -18 -17 -16 -15 -14 -13 -12 -11
-10 -9 -8 -7 -6 -5 -4 -3 -2 -1
0 1 2 3 4 5 6 7 8 9
10 11 12 13 14 15 16 17 18 19
20 21 22 23 24 25 26 27 28 29
30 31 32 33 34 35 36 37 38 39
40 41 42 43 44 45 46 47 48 49
50 51 52 53 54 55 56 57 58 59
60 61 62 63 64 65 66 67 68 69

<graph>{"legends":[],"scales":[{"type":"linear","name":"x","zero":false,"domain":{"data":"chart","field":"x"},"range":"width","nice":true},{"type":"linear","name":"y","domain":{"data":"chart","field":"y"},"zero":false,"range":"height","nice":true},{"domain":{"data":"chart","field":"series"},"type":"ordinal","name":"color","range":["red"]}],"version":2,"marks":[{"type":"line","properties":{"hover":{"stroke":{"value":"red"}},"update":{"stroke":{"scale":"color","field":"series"}},"enter":{"y":{"scale":"y","field":"y"},"x":{"scale":"x","field":"x"},"stroke":{"scale":"color","field":"series"},"strokeWidth":{"value":2.5}}},"from":{"data":"chart"}}],"height":180,"axes":[{"type":"x","title":"Celsius","scale":"x","format":"d","properties":{"title":{"fill":{"value":"#54595d"}},"grid":{"stroke":{"value":"#54595d"}},"ticks":{"stroke":{"value":"#54595d"}},"axis":{"strokeWidth":{"value":2},"stroke":{"value":"#54595d"}},"labels":{"fill":{"value":"#54595d"}}},"grid":false},{"type":"y","title":"Red","scale":"y","format":"d","properties":{"title":{"fill":{"value":"#54595d"}},"grid":{"stroke":{"value":"#54595d"}},"ticks":{"stroke":{"value":"#54595d"}},"axis":{"strokeWidth":{"value":2},"stroke":{"value":"#54595d"}},"labels":{"fill":{"value":"#54595d"}}},"grid":false}],"data":[{"format":{"parse":{"y":"integer","x":"integer"},"type":"json"},"name":"chart","values":[{"y":0,"series":"y","x":-90},{"y":0,"series":"y","x":-89},{"y":0,"series":"y","x":-88},{"y":0,"series":"y","x":-87},{"y":0,"series":"y","x":-86},{"y":0,"series":"y","x":-85},{"y":0,"series":"y","x":-84},{"y":0,"series":"y","x":-83},{"y":0,"series":"y","x":-82},{"y":0,"series":"y","x":-81},{"y":0,"series":"y","x":-80},{"y":0,"series":"y","x":-79},{"y":0,"series":"y","x":-78},{"y":0,"series":"y","x":-77},{"y":0,"series":"y","x":-76},{"y":0,"series":"y","x":-75},{"y":0,"series":"y","x":-74},{"y":0,"series":"y","x":-73},{"y":0,"series":"y","x":-72},{"y":0,"series":"y","x":-71},{"y":0,"series":"y","x":-70},{"y":0,"series":"y","x":-69},{"y":0,"series":"y","x":-68},{"y":0,"series":"y","x":-67},{"y":0,"series":"y","x":-66},{"y":0,"series":"y","x":-65},{"y":0,"series":"y","x":-64},{"y":0,"series":"y","x":-63},{"y":0,"series":"y","x":-62},{"y":0,"series":"y","x":-61},{"y":0,"series":"y","x":-60},{"y":0,"series":"y","x":-59},{"y":0,"series":"y","x":-58},{"y":0,"series":"y","x":-57},{"y":0,"series":"y","x":-56},{"y":0,"series":"y","x":-55},{"y":0,"series":"y","x":-54},{"y":0,"series":"y","x":-53},{"y":0,"series":"y","x":-52},{"y":0,"series":"y","x":-51},{"y":0,"series":"y","x":-50},{"y":0,"series":"y","x":-49},{"y":0,"series":"y","x":-48},{"y":0,"series":"y","x":-47},{"y":0,"series":"y","x":-46},{"y":0,"series":"y","x":-45},{"y":0,"series":"y","x":-44},{"y":0,"series":"y","x":-43},{"y":4,"series":"y","x":-42},{"y":9,"series":"y","x":-41},{"y":14,"series":"y","x":-40},{"y":20,"series":"y","x":-39},{"y":25,"series":"y","x":-38},{"y":31,"series":"y","x":-37},{"y":36,"series":"y","x":-36},{"y":41,"series":"y","x":-35},{"y":47,"series":"y","x":-34},{"y":52,"series":"y","x":-33},{"y":58,"series":"y","x":-32},{"y":63,"series":"y","x":-31},{"y":68,"series":"y","x":-30},{"y":74,"series":"y","x":-29},{"y":79,"series":"y","x":-28},{"y":85,"series":"y","x":-27},{"y":90,"series":"y","x":-26},{"y":95,"series":"y","x":-25},{"y":101,"series":"y","x":-24},{"y":106,"series":"y","x":-23},{"y":111,"series":"y","x":-22},{"y":117,"series":"y","x":-21},{"y":122,"series":"y","x":-20},{"y":128,"series":"y","x":-19},{"y":133,"series":"y","x":-18},{"y":138,"series":"y","x":-17},{"y":144,"series":"y","x":-16},{"y":149,"series":"y","x":-15},{"y":155,"series":"y","x":-14},{"y":160,"series":"y","x":-13},{"y":165,"series":"y","x":-12},{"y":171,"series":"y","x":-11},{"y":176,"series":"y","x":-10},{"y":182,"series":"y","x":-9},{"y":187,"series":"y","x":-8},{"y":192,"series":"y","x":-7},{"y":198,"series":"y","x":-6},{"y":203,"series":"y","x":-5},{"y":209,"series":"y","x":-4},{"y":214,"series":"y","x":-3},{"y":219,"series":"y","x":-2},{"y":225,"series":"y","x":-1},{"y":230,"series":"y","x":0},{"y":236,"series":"y","x":1},{"y":241,"series":"y","x":2},{"y":246,"series":"y","x":3},{"y":252,"series":"y","x":4},{"y":255,"series":"y","x":5},{"y":255,"series":"y","x":6},{"y":255,"series":"y","x":7},{"y":255,"series":"y","x":8},{"y":255,"series":"y","x":9},{"y":255,"series":"y","x":10},{"y":255,"series":"y","x":11},{"y":255,"series":"y","x":12},{"y":255,"series":"y","x":13},{"y":255,"series":"y","x":14},{"y":255,"series":"y","x":15},{"y":255,"series":"y","x":16},{"y":255,"series":"y","x":17},{"y":255,"series":"y","x":18},{"y":255,"series":"y","x":19},{"y":255,"series":"y","x":20},{"y":255,"series":"y","x":21},{"y":255,"series":"y","x":22},{"y":255,"series":"y","x":23},{"y":255,"series":"y","x":24},{"y":255,"series":"y","x":25},{"y":255,"series":"y","x":26},{"y":255,"series":"y","x":27},{"y":255,"series":"y","x":28},{"y":255,"series":"y","x":29},{"y":255,"series":"y","x":30},{"y":255,"series":"y","x":31},{"y":255,"series":"y","x":32},{"y":255,"series":"y","x":33},{"y":218,"series":"y","x":34},{"y":182,"series":"y","x":35},{"y":145,"series":"y","x":36},{"y":109,"series":"y","x":37},{"y":72,"series":"y","x":38},{"y":36,"series":"y","x":39},{"y":0,"series":"y","x":40},{"y":0,"series":"y","x":41},{"y":0,"series":"y","x":42},{"y":0,"series":"y","x":43},{"y":0,"series":"y","x":44},{"y":0,"series":"y","x":45},{"y":0,"series":"y","x":46},{"y":0,"series":"y","x":47},{"y":0,"series":"y","x":48},{"y":0,"series":"y","x":49},{"y":0,"series":"y","x":50},{"y":0,"series":"y","x":51},{"y":0,"series":"y","x":52},{"y":0,"series":"y","x":53},{"y":0,"series":"y","x":54},{"y":0,"series":"y","x":55},{"y":0,"series":"y","x":56},{"y":0,"series":"y","x":57},{"y":0,"series":"y","x":58},{"y":0,"series":"y","x":59},{"y":0,"series":"y","x":60},{"y":0,"series":"y","x":61},{"y":0,"series":"y","x":62},{"y":0,"series":"y","x":63},{"y":0,"series":"y","x":64},{"y":0,"series":"y","x":65},{"y":0,"series":"y","x":66},{"y":0,"series":"y","x":67},{"y":0,"series":"y","x":68},{"y":0,"series":"y","x":69}]}],"width":600}</graph>

<graph>{"legends":[],"scales":[{"type":"linear","name":"x","zero":false,"domain":{"data":"chart","field":"x"},"range":"width","nice":true},{"type":"linear","name":"y","domain":{"data":"chart","field":"y"},"zero":false,"range":"height","nice":true},{"domain":{"data":"chart","field":"series"},"type":"ordinal","name":"color","range":["green"]}],"version":2,"marks":[{"type":"line","properties":{"hover":{"stroke":{"value":"red"}},"update":{"stroke":{"scale":"color","field":"series"}},"enter":{"y":{"scale":"y","field":"y"},"x":{"scale":"x","field":"x"},"stroke":{"scale":"color","field":"series"},"strokeWidth":{"value":2.5}}},"from":{"data":"chart"}}],"height":180,"axes":[{"type":"x","title":"Celsius","scale":"x","format":"d","properties":{"title":{"fill":{"value":"#54595d"}},"grid":{"stroke":{"value":"#54595d"}},"ticks":{"stroke":{"value":"#54595d"}},"axis":{"strokeWidth":{"value":2},"stroke":{"value":"#54595d"}},"labels":{"fill":{"value":"#54595d"}}},"grid":false},{"type":"y","title":"Green","scale":"y","format":"d","properties":{"title":{"fill":{"value":"#54595d"}},"grid":{"stroke":{"value":"#54595d"}},"ticks":{"stroke":{"value":"#54595d"}},"axis":{"strokeWidth":{"value":2},"stroke":{"value":"#54595d"}},"labels":{"fill":{"value":"#54595d"}}},"grid":false}],"data":[{"format":{"parse":{"y":"integer","x":"integer"},"type":"json"},"name":"chart","values":[{"y":0,"series":"y","x":-90},{"y":0,"series":"y","x":-89},{"y":0,"series":"y","x":-88},{"y":0,"series":"y","x":-87},{"y":0,"series":"y","x":-86},{"y":0,"series":"y","x":-85},{"y":0,"series":"y","x":-84},{"y":0,"series":"y","x":-83},{"y":0,"series":"y","x":-82},{"y":0,"series":"y","x":-81},{"y":0,"series":"y","x":-80},{"y":0,"series":"y","x":-79},{"y":0,"series":"y","x":-78},{"y":0,"series":"y","x":-77},{"y":0,"series":"y","x":-76},{"y":0,"series":"y","x":-75},{"y":0,"series":"y","x":-74},{"y":0,"series":"y","x":-73},{"y":0,"series":"y","x":-72},{"y":0,"series":"y","x":-71},{"y":0,"series":"y","x":-70},{"y":0,"series":"y","x":-69},{"y":0,"series":"y","x":-68},{"y":0,"series":"y","x":-67},{"y":0,"series":"y","x":-66},{"y":0,"series":"y","x":-65},{"y":0,"series":"y","x":-64},{"y":0,"series":"y","x":-63},{"y":0,"series":"y","x":-62},{"y":0,"series":"y","x":-61},{"y":0,"series":"y","x":-60},{"y":0,"series":"y","x":-59},{"y":0,"series":"y","x":-58},{"y":0,"series":"y","x":-57},{"y":0,"series":"y","x":-56},{"y":0,"series":"y","x":-55},{"y":0,"series":"y","x":-54},{"y":0,"series":"y","x":-53},{"y":0,"series":"y","x":-52},{"y":0,"series":"y","x":-51},{"y":0,"series":"y","x":-50},{"y":0,"series":"y","x":-49},{"y":0,"series":"y","x":-48},{"y":0,"series":"y","x":-47},{"y":0,"series":"y","x":-46},{"y":0,"series":"y","x":-45},{"y":0,"series":"y","x":-44},{"y":0,"series":"y","x":-43},{"y":4,"series":"y","x":-42},{"y":9,"series":"y","x":-41},{"y":14,"series":"y","x":-40},{"y":20,"series":"y","x":-39},{"y":25,"series":"y","x":-38},{"y":31,"series":"y","x":-37},{"y":36,"series":"y","x":-36},{"y":41,"series":"y","x":-35},{"y":47,"series":"y","x":-34},{"y":52,"series":"y","x":-33},{"y":58,"series":"y","x":-32},{"y":63,"series":"y","x":-31},{"y":68,"series":"y","x":-30},{"y":74,"series":"y","x":-29},{"y":79,"series":"y","x":-28},{"y":85,"series":"y","x":-27},{"y":90,"series":"y","x":-26},{"y":95,"series":"y","x":-25},{"y":101,"series":"y","x":-24},{"y":106,"series":"y","x":-23},{"y":111,"series":"y","x":-22},{"y":117,"series":"y","x":-21},{"y":122,"series":"y","x":-20},{"y":128,"series":"y","x":-19},{"y":133,"series":"y","x":-18},{"y":138,"series":"y","x":-17},{"y":144,"series":"y","x":-16},{"y":149,"series":"y","x":-15},{"y":155,"series":"y","x":-14},{"y":160,"series":"y","x":-13},{"y":165,"series":"y","x":-12},{"y":171,"series":"y","x":-11},{"y":176,"series":"y","x":-10},{"y":182,"series":"y","x":-9},{"y":187,"series":"y","x":-8},{"y":192,"series":"y","x":-7},{"y":198,"series":"y","x":-6},{"y":203,"series":"y","x":-5},{"y":209,"series":"y","x":-4},{"y":214,"series":"y","x":-3},{"y":219,"series":"y","x":-2},{"y":225,"series":"y","x":-1},{"y":230,"series":"y","x":0},{"y":236,"series":"y","x":1},{"y":241,"series":"y","x":2},{"y":246,"series":"y","x":3},{"y":252,"series":"y","x":4},{"y":250,"series":"y","x":5},{"y":241,"series":"y","x":6},{"y":232,"series":"y","x":7},{"y":223,"series":"y","x":8},{"y":214,"series":"y","x":9},{"y":205,"series":"y","x":10},{"y":196,"series":"y","x":11},{"y":187,"series":"y","x":12},{"y":178,"series":"y","x":13},{"y":170,"series":"y","x":14},{"y":161,"series":"y","x":15},{"y":152,"series":"y","x":16},{"y":143,"series":"y","x":17},{"y":134,"series":"y","x":18},{"y":125,"series":"y","x":19},{"y":116,"series":"y","x":20},{"y":107,"series":"y","x":21},{"y":98,"series":"y","x":22},{"y":89,"series":"y","x":23},{"y":80,"series":"y","x":24},{"y":71,"series":"y","x":25},{"y":62,"series":"y","x":26},{"y":53,"series":"y","x":27},{"y":44,"series":"y","x":28},{"y":35,"series":"y","x":29},{"y":26,"series":"y","x":30},{"y":17,"series":"y","x":31},{"y":8,"series":"y","x":32},{"y":0,"series":"y","x":33},{"y":0,"series":"y","x":34},{"y":0,"series":"y","x":35},{"y":0,"series":"y","x":36},{"y":0,"series":"y","x":37},{"y":0,"series":"y","x":38},{"y":0,"series":"y","x":39},{"y":0,"series":"y","x":40},{"y":0,"series":"y","x":41},{"y":0,"series":"y","x":42},{"y":0,"series":"y","x":43},{"y":0,"series":"y","x":44},{"y":0,"series":"y","x":45},{"y":0,"series":"y","x":46},{"y":0,"series":"y","x":47},{"y":0,"series":"y","x":48},{"y":0,"series":"y","x":49},{"y":0,"series":"y","x":50},{"y":0,"series":"y","x":51},{"y":0,"series":"y","x":52},{"y":0,"series":"y","x":53},{"y":0,"series":"y","x":54},{"y":0,"series":"y","x":55},{"y":0,"series":"y","x":56},{"y":0,"series":"y","x":57},{"y":0,"series":"y","x":58},{"y":0,"series":"y","x":59},{"y":0,"series":"y","x":60},{"y":0,"series":"y","x":61},{"y":0,"series":"y","x":62},{"y":0,"series":"y","x":63},{"y":0,"series":"y","x":64},{"y":0,"series":"y","x":65},{"y":0,"series":"y","x":66},{"y":0,"series":"y","x":67},{"y":0,"series":"y","x":68},{"y":0,"series":"y","x":69}]}],"width":600}</graph>

<graph>{"legends":[],"scales":[{"type":"linear","name":"x","zero":false,"domain":{"data":"chart","field":"x"},"range":"width","nice":true},{"type":"linear","name":"y","domain":{"data":"chart","field":"y"},"zero":false,"range":"height","nice":true},{"domain":{"data":"chart","field":"series"},"type":"ordinal","name":"color","range":["blue"]}],"version":2,"marks":[{"type":"line","properties":{"hover":{"stroke":{"value":"red"}},"update":{"stroke":{"scale":"color","field":"series"}},"enter":{"y":{"scale":"y","field":"y"},"x":{"scale":"x","field":"x"},"stroke":{"scale":"color","field":"series"},"strokeWidth":{"value":2.5}}},"from":{"data":"chart"}}],"height":180,"axes":[{"type":"x","title":"Celsius","scale":"x","format":"d","properties":{"title":{"fill":{"value":"#54595d"}},"grid":{"stroke":{"value":"#54595d"}},"ticks":{"stroke":{"value":"#54595d"}},"axis":{"strokeWidth":{"value":2},"stroke":{"value":"#54595d"}},"labels":{"fill":{"value":"#54595d"}}},"grid":false},{"type":"y","title":"Blue","scale":"y","format":"d","properties":{"title":{"fill":{"value":"#54595d"}},"grid":{"stroke":{"value":"#54595d"}},"ticks":{"stroke":{"value":"#54595d"}},"axis":{"strokeWidth":{"value":2},"stroke":{"value":"#54595d"}},"labels":{"fill":{"value":"#54595d"}}},"grid":false}],"data":[{"format":{"parse":{"y":"integer","x":"integer"},"type":"json"},"name":"chart","values":[{"y":0,"series":"y","x":-90},{"y":5,"series":"y","x":-89},{"y":10,"series":"y","x":-88},{"y":16,"series":"y","x":-87},{"y":21,"series":"y","x":-86},{"y":27,"series":"y","x":-85},{"y":32,"series":"y","x":-84},{"y":37,"series":"y","x":-83},{"y":43,"series":"y","x":-82},{"y":48,"series":"y","x":-81},{"y":54,"series":"y","x":-80},{"y":59,"series":"y","x":-79},{"y":64,"series":"y","x":-78},{"y":70,"series":"y","x":-77},{"y":75,"series":"y","x":-76},{"y":81,"series":"y","x":-75},{"y":86,"series":"y","x":-74},{"y":91,"series":"y","x":-73},{"y":97,"series":"y","x":-72},{"y":102,"series":"y","x":-71},{"y":108,"series":"y","x":-70},{"y":113,"series":"y","x":-69},{"y":118,"series":"y","x":-68},{"y":124,"series":"y","x":-67},{"y":129,"series":"y","x":-66},{"y":135,"series":"y","x":-65},{"y":140,"series":"y","x":-64},{"y":145,"series":"y","x":-63},{"y":151,"series":"y","x":-62},{"y":156,"series":"y","x":-61},{"y":162,"series":"y","x":-60},{"y":167,"series":"y","x":-59},{"y":172,"series":"y","x":-58},{"y":178,"series":"y","x":-57},{"y":183,"series":"y","x":-56},{"y":189,"series":"y","x":-55},{"y":194,"series":"y","x":-54},{"y":199,"series":"y","x":-53},{"y":205,"series":"y","x":-52},{"y":210,"series":"y","x":-51},{"y":216,"series":"y","x":-50},{"y":221,"series":"y","x":-49},{"y":226,"series":"y","x":-48},{"y":232,"series":"y","x":-47},{"y":237,"series":"y","x":-46},{"y":243,"series":"y","x":-45},{"y":248,"series":"y","x":-44},{"y":253,"series":"y","x":-43},{"y":255,"series":"y","x":-42},{"y":255,"series":"y","x":-41},{"y":255,"series":"y","x":-40},{"y":255,"series":"y","x":-39},{"y":255,"series":"y","x":-38},{"y":255,"series":"y","x":-37},{"y":255,"series":"y","x":-36},{"y":255,"series":"y","x":-35},{"y":255,"series":"y","x":-34},{"y":255,"series":"y","x":-33},{"y":255,"series":"y","x":-32},{"y":255,"series":"y","x":-31},{"y":255,"series":"y","x":-30},{"y":255,"series":"y","x":-29},{"y":255,"series":"y","x":-28},{"y":255,"series":"y","x":-27},{"y":255,"series":"y","x":-26},{"y":255,"series":"y","x":-25},{"y":255,"series":"y","x":-24},{"y":255,"series":"y","x":-23},{"y":255,"series":"y","x":-22},{"y":255,"series":"y","x":-21},{"y":255,"series":"y","x":-20},{"y":255,"series":"y","x":-19},{"y":255,"series":"y","x":-18},{"y":255,"series":"y","x":-17},{"y":255,"series":"y","x":-16},{"y":255,"series":"y","x":-15},{"y":255,"series":"y","x":-14},{"y":255,"series":"y","x":-13},{"y":255,"series":"y","x":-12},{"y":255,"series":"y","x":-11},{"y":255,"series":"y","x":-10},{"y":255,"series":"y","x":-9},{"y":255,"series":"y","x":-8},{"y":255,"series":"y","x":-7},{"y":255,"series":"y","x":-6},{"y":255,"series":"y","x":-5},{"y":255,"series":"y","x":-4},{"y":255,"series":"y","x":-3},{"y":255,"series":"y","x":-2},{"y":255,"series":"y","x":-1},{"y":255,"series":"y","x":0},{"y":255,"series":"y","x":1},{"y":255,"series":"y","x":2},{"y":255,"series":"y","x":3},{"y":255,"series":"y","x":4},{"y":248,"series":"y","x":5},{"y":234,"series":"y","x":6},{"y":220,"series":"y","x":7},{"y":206,"series":"y","x":8},{"y":192,"series":"y","x":9},{"y":179,"series":"y","x":10},{"y":165,"series":"y","x":11},{"y":151,"series":"y","x":12},{"y":137,"series":"y","x":13},{"y":124,"series":"y","x":14},{"y":110,"series":"y","x":15},{"y":96,"series":"y","x":16},{"y":82,"series":"y","x":17},{"y":68,"series":"y","x":18},{"y":55,"series":"y","x":19},{"y":41,"series":"y","x":20},{"y":27,"series":"y","x":21},{"y":13,"series":"y","x":22},{"y":0,"series":"y","x":23},{"y":0,"series":"y","x":24},{"y":0,"series":"y","x":25},{"y":0,"series":"y","x":26},{"y":0,"series":"y","x":27},{"y":0,"series":"y","x":28},{"y":0,"series":"y","x":29},{"y":0,"series":"y","x":30},{"y":0,"series":"y","x":31},{"y":0,"series":"y","x":32},{"y":0,"series":"y","x":33},{"y":0,"series":"y","x":34},{"y":0,"series":"y","x":35},{"y":0,"series":"y","x":36},{"y":0,"series":"y","x":37},{"y":0,"series":"y","x":38},{"y":0,"series":"y","x":39},{"y":0,"series":"y","x":40},{"y":0,"series":"y","x":41},{"y":0,"series":"y","x":42},{"y":0,"series":"y","x":43},{"y":0,"series":"y","x":44},{"y":0,"series":"y","x":45},{"y":0,"series":"y","x":46},{"y":0,"series":"y","x":47},{"y":0,"series":"y","x":48},{"y":0,"series":"y","x":49},{"y":0,"series":"y","x":50},{"y":0,"series":"y","x":51},{"y":0,"series":"y","x":52},{"y":0,"series":"y","x":53},{"y":0,"series":"y","x":54},{"y":0,"series":"y","x":55},{"y":0,"series":"y","x":56},{"y":0,"series":"y","x":57},{"y":0,"series":"y","x":58},{"y":0,"series":"y","x":59},{"y":0,"series":"y","x":60},{"y":0,"series":"y","x":61},{"y":0,"series":"y","x":62},{"y":0,"series":"y","x":63},{"y":0,"series":"y","x":64},{"y":0,"series":"y","x":65},{"y":0,"series":"y","x":66},{"y":0,"series":"y","x":67},{"y":0,"series":"y","x":68},{"y":0,"series":"y","x":69}]}],"width":600}</graph>


-- Efficient (fast) functions to implement cells in tables of weather data.
-- Temperature conversion is built-in, but for simplicity, temperatures
-- are assumed to be for habitable locations (from -100 to 100 °C).

local MINUS = '−'  -- Unicode U+2212 MINUS SIGN

local function temperature_style(palette, value, out_rgb)
	-- Return style for a table cell based on the given value which
	-- should be a temperature in °C.
	local function style(bg, fg)
		local min, max = unpack(palette.white or { -23, 35 })
		if not fg and value and (value < min or value >= max) then
			fg = 'FFFFFF'
		end
		if fg then
			fg = 'color:#' .. fg .. ';'
		else
			fg = ''
		end
		return 'style="background:#' .. bg .. ';' .. fg .. ' font-size:85%;"'
	end
	if type(value) ~= 'number' then
		return style('FFFFFF', '000000')
	end
	local rgb = out_rgb or {}
	for i, v in ipairs(palette) do
		local a, b, c, d = unpack(v)
		if value <= a then
			rgb[i] = 0
		elseif value < b then
			rgb[i] = (value - a) * 255 / (b - a)
		elseif value <= c then
			rgb[i] = 255
		elseif value < d then
			rgb[i] = 255 - ( (value - c) * 255 / (d - c) )
		else
			rgb[i] = 0
		end
	end
	return style(string.format('%02X%02X%02X', rgb[1], rgb[2], rgb[3]))
end

local function format_cell(palette, value, intext, outtext)
	-- Return one line of wikitext to make a cell in a table.
	if not value then
		return '|\n'
	end
	local text
	if outtext then
		text = intext .. '<br>(' .. outtext .. ')'
	else
		text = intext
	end
	return '| ' .. temperature_style(palette, value) .. ' | ' .. text .. '\n'
end

local function process_temperature(intext, inunit, swap)
	-- Convert °C to °F or vice versa, assuming the temperature is for a
	-- habitable location, well inside the range -100 to 100 °C.
	-- That simplifies determining precision and formatting (no commas are needed).
	-- Return (celsius_value, intext, outtext) if valid; otherwise return nil.
	-- The returned input and output are swapped if requested.
	-- Each returned string has a Unicode MINUS as sign, if negative.
	local invalue = tonumber(intext)
	if not invalue then return nil end
	local integer, dot, decimals = intext:match('^%s*%-?(%d+)(%.?)(%d*)%s*$')
	if not integer then return nil end
	if invalue < 0 then
		intext = MINUS .. integer .. dot .. decimals
	end
	local outtext
	if inunit == 'C' or inunit == 'F' then
		local celsius_value, outvalue
		if inunit == 'C' then
			outvalue = invalue * (9/5) + 32
			celsius_value = invalue
		else
			outvalue = (invalue - 32) * (5/9)
			celsius_value = outvalue
		end
		local precision = dot == '' and 0 or #decimals
		outtext = string.format('%.' .. precision .. 'f', math.abs(outvalue) + 2e-14)
		if outvalue < 0 and tonumber(outtext) ~= 0 then
			-- Don't show minus if result is negative but rounds to zero.
			outtext = MINUS .. outtext
		end
		if swap then
			return celsius_value, outtext, intext
		end
		return celsius_value, intext, outtext
	end
	-- LATER Think about whether a no-conversion option would be useful.
	return invalue, intext, outtext
end

local function temperature_row(palette, row, inunit, swap)
	-- Return 13 lines specifying the style/content of 13 table cells.
	-- Input is 13 space-separated words, each a number (°C or °F).
	-- Any word that is not a number gives a blank cell ("M" for a missing cell).
	-- Any excess words are ignored.
	--
	-- Function  Input   Output
	-- ------------------------
	-- CtoF        C       C/F
	-- FfromC      C       F/C
	-- CfromF      F       C/F
	-- FtoC        F       F/C
	local nrcol = 13
	local results, n = {}, 0
	for word in row:gmatch('%S+') do
		n = n + 1
		if n > nrcol then
			break
		end
		results[n] = format_cell(palette, process_temperature(word, inunit, swap))
	end
	for i = n + 1, nrcol do
		results[i] = format_cell()
	end
	return table.concat(results)
end

local palettes = {
	-- A background color entry in a palette is a table of four numbers,
	-- say { 11, 22, 33, 44 } (values in °C).
	-- That means the color is 0 below 11 and above 44, and is 255 from 22 to 33.
	-- The color rises from 0 to 255 between 11 and 22, and falls between 33 and 44.
	cool = {
		{ -42.75,   4.47, 41.5, 60   },
		{ -42.75,   4.47,  4.5, 41.5 },
		{ -90   , -42.78,  4.5, 23   },
		white = { -23.3, 37.8 },
	},
	cool2 = {
		{ -42.75,   4.5 , 41.5, 56   },
		{ -42.75,   4.5 ,  4.5, 41.5 },
		{ -90   , -42.78,  4.5, 23   },
		white = { -23.3, 35 },
	},
	cool2avg = {
		{ -42.75,   4.5 , 33  , 40   },
		{ -42.75,   4.5 ,  4.5, 33   },
		{ -90   , -42.78,  4.5, 23   },
		white = { -23.3, 35 },
	},
}

local function temperatures(frame, inunit, swap)
	local palette = palettes[frame.palette] or palettes.cool
	return temperature_row(palette, frame.args[1], inunit, swap)
end

local function CtoF(frame)
	return temperatures(frame, 'C')
end

local function CfromF(frame)
	return temperatures(frame, 'F', true)
end

local function FtoC(frame)
	return temperatures(frame, 'F')
end

local function FfromC(frame)
	return temperatures(frame, 'C', true)
end

local chart = [[
{{Graph:Chart
|width=600
|height=180
|xAxisTitle=Celsius
|yAxisTitle=COLOR
|type=line
|x=XVALUES
|y=YVALUES
|colors=COLOR
}}
]]

local function show(frame)
	-- For testing, return wikitext to show graphs of how the red/green/blue colors
	-- vary with temperature, and a table of the resulting colors.
	local function collection()
		-- Return a table to hold items.
		return {
			n = 0,
			add = function (self, item)
				self.n = self.n + 1
				self[self.n] = item
			end,
			join = function (self, sep)
				return table.concat(self, sep)
			end,
		}
	end
	local function make_chart(result, color, xvalues, yvalues)
		result:add('\n')
		local x = xvalues:join(',')
		local y = yvalues:join(',')
		result:add(frame:preprocess((chart:gsub('COLOR', color):gsub('XVALUES', x):gsub('YVALUES', y))))
	end
	local palette = palettes[frame.args.palette] or palettes.cool
	local data = collection()
	local xvals, reds, greens, blues = collection(), collection(), collection(), collection()
	local wikitext = collection()
	wikitext:add('{| class="wikitable"\n|-\n')
	local columns = 0
	for celsius = -90, 69 do
		local rgb = {}
		local style = temperature_style(palette, celsius, rgb)
		local R = math.floor(rgb[1])
		local G = math.floor(rgb[2])
		local B = math.floor(rgb[3])
		xvals:add(celsius)
		reds:add(R)
		greens:add(G)
		blues:add(B)
		data:add({ celsius, R, G, B })
		wikitext:add('| ' .. style .. ' | ' .. celsius .. '\n')
		columns = columns + 1
		if columns >= 10 then
			columns = 0
			wikitext:add('|-\n')
		end
	end
	wikitext:add('|}\n')
	make_chart(wikitext, 'Red', xvals, reds)
	make_chart(wikitext, 'Green', xvals, greens)
	make_chart(wikitext, 'Blue', xvals, blues)
	return wikitext:join()
end

return {
	CtoF = CtoF,
	CfromF = CfromF,
	FtoC = FtoC,
	FfromC = FfromC,
	show = show,
}