Skip to content

Commit 168fd17

Browse files
committed
change width of ohlc to 1
- set ohlc width to 1 - remove duplicate names in tests
1 parent c69c20d commit 168fd17

File tree

2 files changed

+34
-35
lines changed

2 files changed

+34
-35
lines changed

plotly/tests/test_core/test_tools/test_figure_factory.py

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -130,31 +130,31 @@ def test_one_ohlc(self):
130130

131131
# This should create one "increase" (i.e. close > open) ohlc stick
132132

133-
ohlc_incr = tls.FigureFactory.create_ohlc(open=[33.0],
134-
high=[33.2],
135-
low=[32.7],
136-
close=[33.1])
137-
138-
expected_ohlc_incr = {'layout': {'hovermode': 'closest',
139-
'xaxis': {'zeroline': False}},
140-
'data': [{'y': [33.0, 33.0, 33.2, 32.7,
141-
33.1, 33.1, None],
142-
'line': {'width': 1,
143-
'color': '#3D9970'},
144-
'showlegend': False,
145-
'name': 'Increasing',
146-
'text': ('Open', 'Open', 'High', 'Low',
147-
'Close', 'Close', ''),
148-
'mode': 'lines', 'type': 'scatter',
149-
'x': [-0.2, 0, 0, 0, 0, 0.2, None]},
150-
{'y': [], 'line': {'width': 1,
151-
'color': '#FF4136'},
152-
'showlegend': False,
153-
'name': 'Decreasing', 'text': (),
154-
'mode': 'lines', 'type': 'scatter',
155-
'x': []}]}
156-
157-
self.assertEqual(ohlc_incr, expected_ohlc_incr)
133+
ohlc = tls.FigureFactory.create_ohlc(open=[33.0],
134+
high=[33.2],
135+
low=[32.7],
136+
close=[33.1])
137+
138+
expected_ohlc = {'layout': {'hovermode': 'closest',
139+
'xaxis': {'zeroline': False}},
140+
'data': [{'y': [33.0, 33.0, 33.2, 32.7,
141+
33.1, 33.1, None],
142+
'line': {'width': 1,
143+
'color': '#3D9970'},
144+
'showlegend': False,
145+
'name': 'Increasing',
146+
'text': ('Open', 'Open', 'High', 'Low',
147+
'Close', 'Close', ''),
148+
'mode': 'lines', 'type': 'scatter',
149+
'x': [-0.2, 0, 0, 0, 0, 0.2, None]},
150+
{'y': [], 'line': {'width': 1,
151+
'color': '#FF4136'},
152+
'showlegend': False,
153+
'name': 'Decreasing', 'text': (),
154+
'mode': 'lines', 'type': 'scatter',
155+
'x': []}]}
156+
157+
self.assertEqual(ohlc, expected_ohlc)
158158

159159
def test_one_ohlc_increase(self):
160160

@@ -294,11 +294,11 @@ def test_datetime_ohlc(self):
294294
datetime.datetime(year=2014, month=9, day=4),
295295
datetime.datetime(year=2014, month=12, day=5)]
296296

297-
ohlc = tls.FigureFactory.create_ohlc(open_data, high_data,
298-
low_data, close_data,
299-
dates=x)
297+
ohlc_d = tls.FigureFactory.create_ohlc(open_data, high_data,
298+
low_data, close_data,
299+
dates=x)
300300

301-
expe_ohlc = {'data': [{'line': {'color': '#3D9970', 'width': 1},
301+
ex_ohlc_d = {'data': [{'line': {'color': '#3D9970', 'width': 1},
302302
'mode': 'lines',
303303
'name': 'Increasing',
304304
'showlegend': False,
@@ -478,7 +478,7 @@ def test_datetime_ohlc(self):
478478
None]}],
479479
'layout': {'hovermode': 'closest',
480480
'xaxis': {'zeroline': False}}}
481-
self.assertEqual(ohlc, expe_ohlc)
481+
self.assertEqual(ohlc_d, ex_ohlc_d)
482482

483483
def test_datetime_candlestick(self):
484484

plotly/tools.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2187,7 +2187,8 @@ def _make_increasing_ohlc(open, high, low, close, dates, **kwargs):
21872187
kwargs.setdefault('name', 'Increasing')
21882188
showlegend = False
21892189

2190-
kwargs.setdefault('line', dict(color=_DEFAULT_INCREASING_COLOR))
2190+
kwargs.setdefault('line', dict(color=_DEFAULT_INCREASING_COLOR,
2191+
width=1))
21912192
kwargs.setdefault('text', text_increase)
21922193

21932194
ohlc_incr = dict(type='scatter',
@@ -2218,7 +2219,8 @@ def _make_decreasing_ohlc(open, high, low, close, dates, **kwargs):
22182219
flat_decrease_y,
22192220
text_decrease) = _OHLC(open, high, low, close, dates).get_decrease()
22202221

2221-
kwargs.setdefault('line', dict(color=_DEFAULT_DECREASING_COLOR))
2222+
kwargs.setdefault('line', dict(color=_DEFAULT_DECREASING_COLOR,
2223+
width=1))
22222224
kwargs.setdefault('text', text_decrease)
22232225
kwargs.setdefault('showlegend', False)
22242226
kwargs.setdefault('name', 'Decreasing')
@@ -2628,13 +2630,10 @@ def create_candlestick(open, high, low, close,
26282630
py.iplot(fig, filename='finance/simple-candlestick', validate=False)
26292631
```
26302632
"""
2631-
FigureFactory.validate_ohlc(open, high, low, close, direction,
2632-
**kwargs)
26332633
if dates is not None:
26342634
TraceFactory.validate_equal_length(open, high, low, close, dates)
26352635
else:
26362636
TraceFactory.validate_equal_length(open, high, low, close)
2637-
26382637
FigureFactory.validate_ohlc(open, high, low, close, direction,
26392638
**kwargs)
26402639

0 commit comments

Comments
 (0)