Skip to content

Commit 6d91d4e

Browse files
committed
width update
- remove candlestick width=4 (leave as default 2) - change ohlc default to 1 - add bar gap to candlestick layout
1 parent 5ba6283 commit 6d91d4e

File tree

2 files changed

+33
-38
lines changed

2 files changed

+33
-38
lines changed

plotly/tests/test_core/test_tools/test_figure_factory.py

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def test_one_ohlc(self):
139139
'xaxis': {'zeroline': False}},
140140
'data': [{'y': [33.0, 33.0, 33.2, 32.7,
141141
33.1, 33.1, None],
142-
'line': {'color': 'rgb(44, 160, 44)'},
142+
'line': {'color': '#3D9970'},
143143
'showlegend': False,
144144
'name': 'Increasing',
145145
'text': ('Open', 'Open', 'High', 'Low',
@@ -148,7 +148,7 @@ def test_one_ohlc(self):
148148
'type': 'scatter',
149149
'x': [-0.2, 0, 0, 0, 0, 0.2, None]},
150150
{'y': [],
151-
'line': {'color': 'rgb(214, 39, 40)'},
151+
'line': {'color': '#FF4136'},
152152
'showlegend': False,
153153
'name': 'Decreasing',
154154
'text': (),
@@ -172,7 +172,7 @@ def test_one_ohlc_increase(self):
172172
'xaxis': {'zeroline': False}},
173173
'data': [{'y': [33.0, 33.0, 33.2, 32.7,
174174
33.1, 33.1, None],
175-
'line': {'color': 'rgb(44, 160, 44)'},
175+
'line': {'color': '#3D9970'},
176176
'showlegend': False,
177177
'name': 'Increasing',
178178
'text': ('Open', 'Open', 'High', 'Low',
@@ -198,7 +198,7 @@ def test_one_ohlc_decrease(self):
198198
'xaxis': {'zeroline': False}},
199199
'data': [{'y': [33.0, 33.0, 33.2, 30.7,
200200
31.1, 31.1, None],
201-
'line': {'color': 'rgb(214, 39, 40)'},
201+
'line': {'color': '#FF4136'},
202202
'showlegend': False,
203203
'name': 'Decreasing',
204204
'text': ('Open', 'Open', 'High', 'Low',
@@ -230,18 +230,16 @@ def test_one_candlestick(self):
230230
'x': [0],
231231
'legendgroup': 'Increasing'},
232232
{'y': [0.10000000000000142],
233-
'line': {'width': 4,
234-
'color': 'rgb(44, 160, 44)'},
233+
'line': {'color': '#3D9970'},
235234
'hoverinfo': 'none',
236-
'marker': {'color': 'rgb(44, 160, 44)'},
235+
'marker': {'color': '#3D9970'},
237236
'showlegend': False,
238237
'legendgroup': 'Increasing',
239238
'name': 'Increasing',
240239
'type': 'bar', 'x': [0]},
241240
{'y': [32.7, 33.0, 33.1, 33.2, None],
242-
'line': {'width': 4,
243-
'color': 'rgb(44, 160, 44)'},
244-
'marker': {'color': 'rgb(44, 160, 44)'},
241+
'line': {'color': '#3D9970'},
242+
'marker': {'color': '#3D9970'},
245243
'showlegend': False,
246244
'legendgroup': 'Increasing',
247245
'name': 'Increasing',
@@ -257,18 +255,16 @@ def test_one_candlestick(self):
257255
'x': [],
258256
'legendgroup': 'Decreasing'},
259257
{'y': [],
260-
'line': {'width': 4,
261-
'color': 'rgb(214, 39, 40)'},
258+
'line': {'color': '#FF4136'},
262259
'hoverinfo': 'none',
263-
'marker': {'color': 'rgb(214, 39, 40)'},
260+
'marker': {'color': '#FF4136'},
264261
'showlegend': False,
265262
'legendgroup': 'Decreasing',
266263
'name': 'Decreasing',
267264
'type': 'bar', 'x': []},
268265
{'y': [],
269-
'line': {'width': 4,
270-
'color': 'rgb(214, 39, 40)'},
271-
'marker': {'color': 'rgb(214, 39, 40)'},
266+
'line': {'color': '#FF4136'},
267+
'marker': {'color': '#FF4136'},
272268
'showlegend': False,
273269
'legendgroup': 'Decreasing',
274270
'name': 'Decreasing',
@@ -308,7 +304,7 @@ def test_datetime_ohlc(self):
308304
None, 33.05, 33.05, 33.25, 32.75, 33.1,
309305
33.1, None, 33.5, 33.5, 34.62, 32.87, 33.7,
310306
33.7, None],
311-
'line': {'color': 'rgb(44, 160, 44)'},
307+
'line': {'color': '#3D9970'},
312308
'showlegend': False, 'name': 'Increasing',
313309
'text': ('Open', 'Open', 'High', 'Low', 'Close',
314310
'Close', '', 'Open', 'Open', 'High',
@@ -350,7 +346,7 @@ def test_datetime_ohlc(self):
350346
33.37, None, 34.12, 34.12, 35.18, 30.81,
351347
31.18, 31.18, None, 33.31, 33.31, 35.37,
352348
32.75, 32.93, 32.93, None],
353-
'line': {'color': 'rgb(214, 39, 40)'},
349+
'line': {'color': '#FF4136'},
354350
'showlegend': False, 'name': 'Decreasing',
355351
'text': ('Open', 'Open', 'High', 'Low', 'Close',
356352
'Close', '', 'Open', 'Open', 'High',
@@ -426,9 +422,9 @@ def test_datetime_candlestick(self):
426422
'legendgroup': 'Increasing'},
427423
{'y': [1.0900000000000034, 1.1199999999999974,
428424
0.05000000000000426, 0.20000000000000284],
429-
'line': {'width': 4, 'color': 'rgb(44, 160, 44)'},
425+
'line': {'color': '#3D9970'},
430426
'hoverinfo': 'none',
431-
'marker': {'color': 'rgb(44, 160, 44)'},
427+
'marker': {'color': '#3D9970'},
432428
'showlegend': False,
433429
'legendgroup': 'Increasing',
434430
'name': 'Increasing',
@@ -441,9 +437,8 @@ def test_datetime_candlestick(self):
441437
33.18, 34.25, None, 32.75, 33.05, 33.1,
442438
33.25, None, 32.87, 33.5, 33.7, 34.62,
443439
None],
444-
'line': {'width': 4,
445-
'color': 'rgb(44, 160, 44)'},
446-
'marker': {'color': 'rgb(44, 160, 44)'},
440+
'line': {'color': '#3D9970'},
441+
'marker': {'color': '#3D9970'},
447442
'showlegend': False,
448443
'legendgroup': 'Increasing',
449444
'name': 'Increasing',
@@ -480,9 +475,9 @@ def test_datetime_candlestick(self):
480475
'legendgroup': 'Decreasing'},
481476
{'y': [1.3800000000000026, 0.13000000000000256,
482477
2.9399999999999977, 0.38000000000000256],
483-
'line': {'width': 4, 'color': 'rgb(214, 39, 40)'},
478+
'line': {'color': '#FF4136'},
484479
'hoverinfo': 'none',
485-
'marker': {'color': 'rgb(214, 39, 40)'},
480+
'marker': {'color': '#FF4136'},
486481
'showlegend': False, 'legendgroup': 'Decreasing',
487482
'name': 'Decreasing', 'type': 'bar',
488483
'x': [datetime.datetime(2013, 6, 5, 0, 0),
@@ -493,8 +488,8 @@ def test_datetime_candlestick(self):
493488
33.37, 33.5, 33.62, None, 30.81, 31.18,
494489
34.12, 35.18, None, 32.75, 32.93, 33.31,
495490
35.37, None],
496-
'line': {'width': 4, 'color': 'rgb(214, 39, 40)'},
497-
'marker': {'color': 'rgb(214, 39, 40)'},
491+
'line': {'color': '#FF4136'},
492+
'marker': {'color': '#FF4136'},
498493
'showlegend': False, 'legendgroup': 'Decreasing',
499494
'name': 'Decreasing',
500495
'text': ('Low', 'Close', 'Open', 'High', '',

plotly/tools.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2184,7 +2184,7 @@ def _make_increasing_ohlc(open, high, low, close, dates, **kwargs):
21842184
kwargs.setdefault('name', 'Increasing')
21852185
showlegend = False
21862186

2187-
kwargs.setdefault('line', dict(color='rgb(44, 160, 44)'))
2187+
kwargs.setdefault('line', dict(color='#3D9970', width=1))
21882188
kwargs.setdefault('text', text_increase)
21892189

21902190
ohlc_incr = dict(type='scatter',
@@ -2215,7 +2215,7 @@ def _make_decreasing_ohlc(open, high, low, close, dates, **kwargs):
22152215
flat_decrease_y,
22162216
text_decrease) = _OHLC(open, high, low, close, dates).get_decrease()
22172217

2218-
kwargs.setdefault('line', dict(color='rgb(214, 39, 40)'))
2218+
kwargs.setdefault('line', dict(color='#FF4136', width=1))
22192219
kwargs.setdefault('text', text_decrease)
22202220
kwargs.setdefault('showlegend', False)
22212221
kwargs.setdefault('name', 'Decreasing')
@@ -2482,8 +2482,8 @@ def _make_increasing_candle(open, high, low, close, dates, **kwargs):
24822482
kwargs.setdefault('name', 'Increasing')
24832483
showlegend = False
24842484

2485-
kwargs.setdefault('marker', dict(color='rgb(44, 160, 44)'))
2486-
kwargs.setdefault('line', dict(color='rgb(44, 160, 44)', width=4))
2485+
kwargs.setdefault('marker', dict(color='#3D9970'))
2486+
kwargs.setdefault('line', dict(color='#3D9970'))
24872487

24882488
hidden_bar_incr = dict(type='bar',
24892489
x=increase_x,
@@ -2537,8 +2537,8 @@ def _make_decreasing_candle(open, high, low, close, dates, **kwargs):
25372537
stick_decrease_x) = (_Candlestick(open, high, low, close, dates,
25382538
**kwargs).get_candle_decrease())
25392539

2540-
kwargs.setdefault('marker', dict(color='rgb(214, 39, 40)'))
2541-
kwargs.setdefault('line', dict(color='rgb(214, 39, 40)', width=4))
2540+
kwargs.setdefault('marker', dict(color='#FF4136'))
2541+
kwargs.setdefault('line', dict(color='#FF4136'))
25422542
kwargs.setdefault('name', 'Decreasing')
25432543

25442544
hidden_bar_decr = dict(type='bar',
@@ -2690,8 +2690,7 @@ def create_candlestick(open, high, low, close,
26902690
direction='increasing',
26912691
line=Line(color='rgb(204,
26922692
229,
2693-
255)',
2694-
width=4),
2693+
255)''),
26952694
marker=Marker(color='rgb(204,
26962695
229,
26972696
255)')
@@ -2705,8 +2704,7 @@ def create_candlestick(open, high, low, close,
27052704
direction='decreasing',
27062705
line=Line(color='rgb(160,
27072706
160,
2708-
160)',
2709-
width=4),
2707+
160)'),
27102708
marker=Marker(color='rgb(160,
27112709
160,
27122710
160)'),
@@ -2758,7 +2756,9 @@ def create_candlestick(open, high, low, close,
27582756
data = candle_incr_data + candle_decr_data
27592757

27602758
layout = dict(barmode='stack',
2761-
yaxis=dict(range=[(min(low) -
2759+
bargroupgap=0.2,
2760+
yaxis=dict(fixedrange=True,
2761+
range=[(min(low) -
27622762
((max(high) - min(low)) * .1)),
27632763
(max(high) +
27642764
((max(high) - min(low)) * .1))]))

0 commit comments

Comments
 (0)