Skip to content

Commit b7edba4

Browse files
committed
update docstring
1 parent 056e510 commit b7edba4

File tree

1 file changed

+39
-44
lines changed

1 file changed

+39
-44
lines changed

packages/python/plotly/plotly/figure_factory/_candlestick.py

Lines changed: 39 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -97,76 +97,73 @@ def make_decreasing_candle(open, high, low, close, dates, **kwargs):
9797

9898
def create_candlestick(open, high, low, close, dates=None, direction="both", **kwargs):
9999
"""
100-
**deprecated**, use instead the plotly.graph_objects trace
101-
:class:`plotly.graph_objects.Candlestick`
102-
103-
:param (list) open: opening values
104-
:param (list) high: high values
105-
:param (list) low: low values
106-
:param (list) close: closing values
107-
:param (list) dates: list of datetime objects. Default: None
108-
:param (string) direction: direction can be 'increasing', 'decreasing',
109-
or 'both'. When the direction is 'increasing', the returned figure
110-
consists of all candlesticks where the close value is greater than
111-
the corresponding open value, and when the direction is
112-
'decreasing', the returned figure consists of all candlesticks
113-
where the close value is less than or equal to the corresponding
114-
open value. When the direction is 'both', both increasing and
115-
decreasing candlesticks are returned. Default: 'both'
116-
:param kwargs: kwargs passed through plotly.graph_objs.Scatter.
117-
These kwargs describe other attributes about the ohlc Scatter trace
118-
such as the color or the legend name. For more information on valid
119-
kwargs call help(plotly.graph_objs.Scatter)
120-
121-
:rtype (dict): returns a representation of candlestick chart figure.
122-
100+
**Deprecated**. Use [`plotly.graph_objs.Candlestick`][plotly.graph_objs.Candlestick] instead.
101+
102+
Parameters
103+
----------
104+
open : list
105+
Opening values.
106+
high : list
107+
High values.
108+
low : list
109+
Low values.
110+
close : list
111+
Closing values.
112+
dates : list of datetime objects
113+
List of datetime objects. Default is None.
114+
direction : str
115+
Direction can be 'increasing', 'decreasing', or 'both'. When the direction is 'increasing',
116+
the returned figure consists of all candlesticks where the close value is greater than
117+
the corresponding open value, and when the direction is 'decreasing', the returned figure
118+
consists of all candlesticks where the close value is less than or equal to the corresponding
119+
open value. When the direction is 'both', both increasing and decreasing candlesticks are
120+
returned. Default is 'both'.
121+
**kwargs
122+
Additional keyword arguments passed through to `plotly.graph_objs.Scatter`.
123+
These kwargs describe other attributes about the OHLC Scatter trace such as the color
124+
or the legend name. For more information on valid kwargs, call `help(plotly.graph_objs.Scatter)`.
125+
126+
Returns
127+
-------
128+
dict
129+
Returns a representation of the candlestick chart figure.
130+
131+
Examples
132+
--------
123133
Example 1: Simple candlestick chart from a Pandas DataFrame
124134
125135
>>> from plotly.figure_factory import create_candlestick
126136
>>> from datetime import datetime
127137
>>> import pandas as pd
128-
129138
>>> df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv')
130-
>>> fig = create_candlestick(df['AAPL.Open'], df['AAPL.High'], df['AAPL.Low'], df['AAPL.Close'],
131-
... dates=df.index)
139+
>>> fig = create_candlestick(df['AAPL.Open'], df['AAPL.High'], df['AAPL.Low'], df['AAPL.Close'], dates=df.index)
132140
>>> fig.show()
133141
134142
Example 2: Customize the candlestick colors
135143
136144
>>> from plotly.figure_factory import create_candlestick
137145
>>> from plotly.graph_objs import Line, Marker
138146
>>> from datetime import datetime
139-
140147
>>> import pandas as pd
141148
>>> df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv')
142-
143149
>>> # Make increasing candlesticks and customize their color and name
144150
>>> fig_increasing = create_candlestick(df['AAPL.Open'], df['AAPL.High'], df['AAPL.Low'], df['AAPL.Close'],
145-
... dates=df.index,
146-
... direction='increasing', name='AAPL',
147-
... marker=Marker(color='rgb(150, 200, 250)'),
148-
... line=Line(color='rgb(150, 200, 250)'))
149-
151+
... dates=df.index, direction='increasing', name='AAPL',
152+
... marker=Marker(color='rgb(150, 200, 250)'), line=Line(color='rgb(150, 200, 250)'))
150153
>>> # Make decreasing candlesticks and customize their color and name
151154
>>> fig_decreasing = create_candlestick(df['AAPL.Open'], df['AAPL.High'], df['AAPL.Low'], df['AAPL.Close'],
152-
... dates=df.index,
153-
... direction='decreasing',
154-
... marker=Marker(color='rgb(128, 128, 128)'),
155-
... line=Line(color='rgb(128, 128, 128)'))
156-
155+
... dates=df.index, direction='decreasing',
156+
... marker=Marker(color='rgb(128, 128, 128)'), line=Line(color='rgb(128, 128, 128)'))
157157
>>> # Initialize the figure
158158
>>> fig = fig_increasing
159-
160159
>>> # Add decreasing data with .extend()
161160
>>> fig.add_trace(fig_decreasing['data']) # doctest: +SKIP
162161
>>> fig.show()
163162
164163
Example 3: Candlestick chart with datetime objects
165164
166165
>>> from plotly.figure_factory import create_candlestick
167-
168166
>>> from datetime import datetime
169-
170167
>>> # Add data
171168
>>> open_data = [33.0, 33.3, 33.5, 33.0, 34.1]
172169
>>> high_data = [33.1, 33.3, 33.6, 33.2, 34.8]
@@ -177,10 +174,8 @@ def create_candlestick(open, high, low, close, dates=None, direction="both", **k
177174
... datetime(year=2013, month=12, day=10),
178175
... datetime(year=2014, month=1, day=10),
179176
... datetime(year=2014, month=2, day=10)]
180-
181177
>>> # Create ohlc
182-
>>> fig = create_candlestick(open_data, high_data,
183-
... low_data, close_data, dates=dates)
178+
>>> fig = create_candlestick(open_data, high_data, low_data, close_data, dates=dates)
184179
>>> fig.show()
185180
"""
186181
if dates is not None:

0 commit comments

Comments
 (0)