Skip to content

Commit 8dd98a0

Browse files
committed
Merge pull request #295 from plotly/Yl-not-YI
Abbreviation for yellow in colorscale names is 'Yl' not 'YI' [fixes #269]
2 parents e39244d + 0d0c297 commit 8dd98a0

File tree

4 files changed

+181
-79
lines changed

4 files changed

+181
-79
lines changed

src/components/colorscale/scales.js

Lines changed: 111 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -10,84 +10,120 @@
1010

1111

1212
module.exports = {
13-
'Greys': [[0,'rgb(0,0,0)'],[1,'rgb(255,255,255)']],
14-
15-
'YIGnBu': [[0,'rgb(8, 29, 88)'],[0.125,'rgb(37, 52, 148)'],
16-
[0.25,'rgb(34, 94, 168)'],[0.375,'rgb(29, 145, 192)'],
17-
[0.5,'rgb(65, 182, 196)'],[0.625,'rgb(127, 205, 187)'],
18-
[0.75,'rgb(199, 233, 180)'],[0.875,'rgb(237, 248, 217)'],
19-
[1,'rgb(255, 255, 217)']],
20-
21-
'Greens': [[0,'rgb(0, 68, 27)'],[0.125,'rgb(0, 109, 44)'],
22-
[0.25,'rgb(35, 139, 69)'],[0.375,'rgb(65, 171, 93)'],
23-
[0.5,'rgb(116, 196, 118)'],[0.625,'rgb(161, 217, 155)'],
24-
[0.75,'rgb(199, 233, 192)'],[0.875,'rgb(229, 245, 224)'],
25-
[1,'rgb(247, 252, 245)']],
26-
27-
'YIOrRd': [[0,'rgb(128, 0, 38)'],[0.125,'rgb(189, 0, 38)'],
28-
[0.25,'rgb(227, 26, 28)'],[0.375,'rgb(252, 78, 42)'],
29-
[0.5,'rgb(253, 141, 60)'],[0.625,'rgb(254, 178, 76)'],
30-
[0.75,'rgb(254, 217, 118)'],[0.875,'rgb(255, 237, 160)'],
31-
[1,'rgb(255, 255, 204)']],
32-
33-
'Bluered': [[0,'rgb(0,0,255)'],[1,'rgb(255,0,0)']],
13+
'Greys': [
14+
[0, 'rgb(0,0,0)'], [1, 'rgb(255,255,255)']
15+
],
16+
17+
'YlGnBu': [
18+
[0, 'rgb(8,29,88)'], [0.125, 'rgb(37,52,148)'],
19+
[0.25, 'rgb(34,94,168)'], [0.375, 'rgb(29,145,192)'],
20+
[0.5, 'rgb(65,182,196)'], [0.625, 'rgb(127,205,187)'],
21+
[0.75, 'rgb(199,233,180)'], [0.875, 'rgb(237,248,217)'],
22+
[1, 'rgb(255,255,217)']
23+
],
24+
25+
'Greens': [
26+
[0, 'rgb(0,68,27)'], [0.125, 'rgb(0,109,44)'],
27+
[0.25, 'rgb(35,139,69)'], [0.375, 'rgb(65,171,93)'],
28+
[0.5, 'rgb(116,196,118)'], [0.625, 'rgb(161,217,155)'],
29+
[0.75, 'rgb(199,233,192)'], [0.875, 'rgb(229,245,224)'],
30+
[1, 'rgb(247,252,245)']
31+
],
32+
33+
'YlOrRd': [
34+
[0, 'rgb(128,0,38)'], [0.125, 'rgb(189,0,38)'],
35+
[0.25, 'rgb(227,26,28)'], [0.375, 'rgb(252,78,42)'],
36+
[0.5, 'rgb(253,141,60)'], [0.625, 'rgb(254,178,76)'],
37+
[0.75, 'rgb(254,217,118)'], [0.875, 'rgb(255,237,160)'],
38+
[1, 'rgb(255,255,204)']
39+
],
40+
41+
'Bluered': [
42+
[0, 'rgb(0,0,255)'], [1, 'rgb(255,0,0)']
43+
],
3444

3545
// modified RdBu based on
3646
// www.sandia.gov/~kmorel/documents/ColorMaps/ColorMapsExpanded.pdf
37-
'RdBu': [[0,'rgb(5, 10, 172)'],[0.35,'rgb(106, 137, 247)'],
38-
[0.5,'rgb(190,190,190)'],[0.6,'rgb(220, 170, 132)'],
39-
[0.7,'rgb(230, 145, 90)'],[1,'rgb(178, 10, 28)']],
47+
'RdBu': [
48+
[0, 'rgb(5,10,172)'], [0.35, 'rgb(106,137,247)'],
49+
[0.5, 'rgb(190,190,190)'], [0.6, 'rgb(220,170,132)'],
50+
[0.7, 'rgb(230,145,90)'], [1, 'rgb(178,10,28)']
51+
],
52+
4053
// Scale for non-negative numeric values
41-
'Reds': [[0, 'rgb(220, 220, 220)'], [0.2,'rgb(245, 195, 157)'],
42-
[0.4,'rgb(245, 160, 105)'], [1, 'rgb(178, 10, 28)']],
54+
'Reds': [
55+
[0, 'rgb(220,220,220)'], [0.2, 'rgb(245,195,157)'],
56+
[0.4, 'rgb(245,160,105)'], [1, 'rgb(178,10,28)']
57+
],
58+
4359
// Scale for non-positive numeric values
44-
'Blues': [[0, 'rgb(5, 10, 172)'], [0.35, 'rgb(40, 60, 190)'],
45-
[0.5, 'rgb(70, 100, 245)'], [0.6, 'rgb(90, 120, 245)'],
46-
[0.7, 'rgb(106, 137, 247)'], [1, 'rgb(220, 220, 220)']],
47-
48-
'Picnic': [[0,'rgb(0,0,255)'],[0.1,'rgb(51,153,255)'],
49-
[0.2,'rgb(102,204,255)'],[0.3,'rgb(153,204,255)'],
50-
[0.4,'rgb(204,204,255)'],[0.5,'rgb(255,255,255)'],
51-
[0.6,'rgb(255,204,255)'],[0.7,'rgb(255,153,255)'],
52-
[0.8,'rgb(255,102,204)'],[0.9,'rgb(255,102,102)'],
53-
[1,'rgb(255,0,0)']],
54-
55-
'Rainbow': [[0,'rgb(150,0,90)'],[0.125,'rgb(0, 0, 200)'],
56-
[0.25,'rgb(0, 25, 255)'],[0.375,'rgb(0, 152, 255)'],
57-
[0.5,'rgb(44, 255, 150)'],[0.625,'rgb(151, 255, 0)'],
58-
[0.75,'rgb(255, 234, 0)'],[0.875,'rgb(255, 111, 0)'],
59-
[1,'rgb(255, 0, 0)']],
60-
61-
'Portland': [[0,'rgb(12,51,131)'],[0.25,'rgb(10,136,186)'],
62-
[0.5,'rgb(242,211,56)'],[0.75,'rgb(242,143,56)'],
63-
[1,'rgb(217,30,30)']],
64-
65-
'Jet': [[0,'rgb(0,0,131)'],[0.125,'rgb(0,60,170)'],
66-
[0.375,'rgb(5,255,255)'],[0.625,'rgb(255,255,0)'],
67-
[0.875,'rgb(250,0,0)'],[1,'rgb(128,0,0)']],
68-
69-
'Hot': [[0,'rgb(0,0,0)'],[0.3,'rgb(230,0,0)'],
70-
[0.6,'rgb(255,210,0)'],[1,'rgb(255,255,255)']],
71-
72-
'Blackbody': [[0,'rgb(0,0,0)'],[0.2,'rgb(230,0,0)'],
73-
[0.4,'rgb(230,210,0)'],[0.7,'rgb(255,255,255)'],
74-
[1,'rgb(160,200,255)']],
75-
76-
'Earth': [[0,'rgb(0,0,130)'],[0.1,'rgb(0,180,180)'],
77-
[0.2,'rgb(40,210,40)'],[0.4,'rgb(230,230,50)'],
78-
[0.6,'rgb(120,70,20)'],[1,'rgb(255,255,255)']],
79-
80-
'Electric': [[0,'rgb(0,0,0)'],[0.15,'rgb(30,0,100)'],
81-
[0.4,'rgb(120,0,100)'],[0.6,'rgb(160,90,0)'],
82-
[0.8,'rgb(230,200,0)'],[1,'rgb(255,250,220)']],
83-
84-
'Viridis': [[0,'#440154'],[0.06274509803921569,'#48186a'],
85-
[0.12549019607843137,'#472d7b'],[0.18823529411764706,'#424086'],
86-
[0.25098039215686274,'#3b528b'],[0.3137254901960784,'#33638d'],
87-
[0.3764705882352941,'#2c728e'],[0.4392156862745098,'#26828e'],
88-
[0.5019607843137255,'#21918c'],[0.5647058823529412,'#1fa088'],
89-
[0.6274509803921569,'#28ae80'],[0.6901960784313725,'#3fbc73'],
90-
[0.7529411764705882,'#5ec962'],[0.8156862745098039,'#84d44b'],
91-
[0.8784313725490196,'#addc30'],[0.9411764705882353,'#d8e219'],
92-
[1,'#fde725']]
60+
'Blues': [
61+
[0, 'rgb(5,10,172)'], [0.35, 'rgb(40,60,190)'],
62+
[0.5, 'rgb(70,100,245)'], [0.6, 'rgb(90,120,245)'],
63+
[0.7, 'rgb(106,137,247)'], [1, 'rgb(220,220,220)']
64+
],
65+
66+
'Picnic': [
67+
[0, 'rgb(0,0,255)'], [0.1, 'rgb(51,153,255)'],
68+
[0.2, 'rgb(102,204,255)'], [0.3, 'rgb(153,204,255)'],
69+
[0.4, 'rgb(204,204,255)'], [0.5, 'rgb(255,255,255)'],
70+
[0.6, 'rgb(255,204,255)'], [0.7, 'rgb(255,153,255)'],
71+
[0.8, 'rgb(255,102,204)'], [0.9, 'rgb(255,102,102)'],
72+
[1, 'rgb(255,0,0)']
73+
],
74+
75+
'Rainbow': [
76+
[0, 'rgb(150,0,90)'], [0.125, 'rgb(0,0,200)'],
77+
[0.25, 'rgb(0,25,255)'], [0.375, 'rgb(0,152,255)'],
78+
[0.5, 'rgb(44,255,150)'], [0.625, 'rgb(151,255,0)'],
79+
[0.75, 'rgb(255,234,0)'], [0.875, 'rgb(255,111,0)'],
80+
[1, 'rgb(255,0,0)']
81+
],
82+
83+
'Portland': [
84+
[0, 'rgb(12,51,131)'], [0.25, 'rgb(10,136,186)'],
85+
[0.5, 'rgb(242,211,56)'], [0.75, 'rgb(242,143,56)'],
86+
[1, 'rgb(217,30,30)']
87+
],
88+
89+
'Jet': [
90+
[0, 'rgb(0,0,131)'], [0.125, 'rgb(0,60,170)'],
91+
[0.375, 'rgb(5,255,255)'], [0.625, 'rgb(255,255,0)'],
92+
[0.875, 'rgb(250,0,0)'], [1, 'rgb(128,0,0)']
93+
],
94+
95+
'Hot': [
96+
[0, 'rgb(0,0,0)'], [0.3, 'rgb(230,0,0)'],
97+
[0.6, 'rgb(255,210,0)'], [1, 'rgb(255,255,255)']
98+
],
99+
100+
'Blackbody': [
101+
[0, 'rgb(0,0,0)'], [0.2, 'rgb(230,0,0)'],
102+
[0.4, 'rgb(230,210,0)'], [0.7, 'rgb(255,255,255)'],
103+
[1, 'rgb(160,200,255)']
104+
],
105+
106+
'Earth': [
107+
[0, 'rgb(0,0,130)'], [0.1, 'rgb(0,180,180)'],
108+
[0.2, 'rgb(40,210,40)'], [0.4, 'rgb(230,230,50)'],
109+
[0.6, 'rgb(120,70,20)'], [1, 'rgb(255,255,255)']
110+
],
111+
112+
'Electric': [
113+
[0, 'rgb(0,0,0)'], [0.15, 'rgb(30,0,100)'],
114+
[0.4, 'rgb(120,0,100)'], [0.6, 'rgb(160,90,0)'],
115+
[0.8, 'rgb(230,200,0)'], [1, 'rgb(255,250,220)']
116+
],
117+
118+
'Viridis': [
119+
[0, '#440154'], [0.06274509803921569, '#48186a'],
120+
[0.12549019607843137, '#472d7b'], [0.18823529411764706, '#424086'],
121+
[0.25098039215686274, '#3b528b'], [0.3137254901960784, '#33638d'],
122+
[0.3764705882352941, '#2c728e'], [0.4392156862745098, '#26828e'],
123+
[0.5019607843137255, '#21918c'], [0.5647058823529412, '#1fa088'],
124+
[0.6274509803921569, '#28ae80'], [0.6901960784313725, '#3fbc73'],
125+
[0.7529411764705882, '#5ec962'], [0.8156862745098039, '#84d44b'],
126+
[0.8784313725490196, '#addc30'], [0.9411764705882353, '#d8e219'],
127+
[1, '#fde725']
128+
]
93129
};

src/plot_api/plot_api.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,7 @@ function cleanData(data, existingData) {
670670

671671
for(var tracei = 0; tracei < data.length; tracei++) {
672672
var trace = data[tracei];
673+
673674
// assign uids to each trace and detect collisions.
674675
if(!('uid' in trace) || suids.indexOf(trace.uid) !== -1) {
675676
var newUid, i;
@@ -750,6 +751,17 @@ function cleanData(data, existingData) {
750751
}
751752
}
752753

754+
// fix typo in colorscale definition
755+
if(Plots.traceIs(trace, '2dMap')) {
756+
if(trace.colorscale === 'YIGnBu') trace.colorscale = 'YlGnBu';
757+
if(trace.colorscale === 'YIOrRd') trace.colorscale = 'YlOrRd';
758+
}
759+
if(Plots.traceIs(trace, 'markerColorscale') && trace.marker) {
760+
var cont = trace.marker;
761+
if(cont.colorscale === 'YIGnBu') cont.colorscale = 'YlGnBu';
762+
if(cont.colorscale === 'YIOrRd') cont.colorscale = 'YlOrRd';
763+
}
764+
753765
// prune empty containers made before the new nestedProperty
754766
if(emptyContainer(trace, 'line')) delete trace.line;
755767
if('marker' in trace) {

test/jasmine/tests/colorscale_test.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ describe('Test colorscale:', function() {
325325
z = [[0, -1.5], [-2, -10]];
326326
calcColorscale(trace, z, '', 'z');
327327
expect(trace.autocolorscale).toBe(true);
328-
expect(trace.colorscale[5]).toEqual([1, 'rgb(220, 220, 220)']);
328+
expect(trace.colorscale[5]).toEqual([1, 'rgb(220,220,220)']);
329329
});
330330

331331
it('should be Blues when the only numerical z <= -0.5', function() {
@@ -338,7 +338,7 @@ describe('Test colorscale:', function() {
338338
z = [[undefined, undefined], [-0.5, undefined]];
339339
calcColorscale(trace, z, '', 'z');
340340
expect(trace.autocolorscale).toBe(true);
341-
expect(trace.colorscale[5]).toEqual([1, 'rgb(220, 220, 220)']);
341+
expect(trace.colorscale[5]).toEqual([1, 'rgb(220,220,220)']);
342342
});
343343

344344
it('should be Reds when the only numerical z >= 0.5', function() {
@@ -351,7 +351,7 @@ describe('Test colorscale:', function() {
351351
z = [[undefined, undefined], [0.5, undefined]];
352352
calcColorscale(trace, z, '', 'z');
353353
expect(trace.autocolorscale).toBe(true);
354-
expect(trace.colorscale[0]).toEqual([0, 'rgb(220, 220, 220)']);
354+
expect(trace.colorscale[0]).toEqual([0, 'rgb(220,220,220)']);
355355
});
356356

357357
it('should be reverse the auto scale when reversescale is true', function() {
@@ -365,7 +365,8 @@ describe('Test colorscale:', function() {
365365
z = [[undefined, undefined], [0.5, undefined]];
366366
calcColorscale(trace, z, '', 'z');
367367
expect(trace.autocolorscale).toBe(true);
368-
expect(trace.colorscale[trace.colorscale.length-1]).toEqual([1, 'rgb(220, 220, 220)']);
368+
expect(trace.colorscale[trace.colorscale.length-1])
369+
.toEqual([1, 'rgb(220,220,220)']);
369370
});
370371

371372
});

test/jasmine/tests/plot_api_test.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ var Bar = require('@src/traces/bar');
77
var Legend = require('@src/components/legend');
88
var pkg = require('../../../package.json');
99

10+
var createGraphDiv = require('../assets/create_graph_div');
11+
var destroyGraphDiv = require('../assets/destroy_graph_div');
12+
1013

1114
describe('Test plot api', function() {
1215
'use strict';
@@ -616,4 +619,54 @@ describe('Test plot api', function() {
616619
expect(gd.data).toEqual(cachedData);
617620
});
618621
});
622+
623+
describe('cleanData', function() {
624+
var gd;
625+
626+
beforeEach(function() {
627+
gd = createGraphDiv();
628+
});
629+
630+
afterEach(destroyGraphDiv);
631+
632+
it('should rename \'YIGnBu\' colorscales YlGnBu (2dMap case)', function() {
633+
var data = [{
634+
type: 'heatmap',
635+
colorscale: 'YIGnBu'
636+
}];
637+
638+
Plotly.plot(gd, data);
639+
expect(gd.data[0].colorscale).toBe('YlGnBu');
640+
});
641+
642+
it('should rename \'YIGnBu\' colorscales YlGnBu (markerColorscale case)', function() {
643+
var data = [{
644+
type: 'scattergeo',
645+
marker: { colorscale: 'YIGnBu' }
646+
}];
647+
648+
Plotly.plot(gd, data);
649+
expect(gd.data[0].marker.colorscale).toBe('YlGnBu');
650+
});
651+
652+
it('should rename \'YIOrRd\' colorscales YlOrRd (2dMap case)', function() {
653+
var data = [{
654+
type: 'contour',
655+
colorscale: 'YIOrRd'
656+
}];
657+
658+
Plotly.plot(gd, data);
659+
expect(gd.data[0].colorscale).toBe('YlOrRd');
660+
});
661+
662+
it('should rename \'YIOrRd\' colorscales YlOrRd (markerColorscale case)', function() {
663+
var data = [{
664+
type: 'scattergeo',
665+
marker: { colorscale: 'YIOrRd' }
666+
}];
667+
668+
Plotly.plot(gd, data);
669+
expect(gd.data[0].marker.colorscale).toBe('YlOrRd');
670+
});
671+
});
619672
});

0 commit comments

Comments
 (0)