@@ -97,76 +97,73 @@ def make_decreasing_candle(open, high, low, close, dates, **kwargs):
97
97
98
98
def create_candlestick (open , high , low , close , dates = None , direction = "both" , ** kwargs ):
99
99
"""
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
+ --------
123
133
Example 1: Simple candlestick chart from a Pandas DataFrame
124
134
125
135
>>> from plotly.figure_factory import create_candlestick
126
136
>>> from datetime import datetime
127
137
>>> import pandas as pd
128
-
129
138
>>> 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)
132
140
>>> fig.show()
133
141
134
142
Example 2: Customize the candlestick colors
135
143
136
144
>>> from plotly.figure_factory import create_candlestick
137
145
>>> from plotly.graph_objs import Line, Marker
138
146
>>> from datetime import datetime
139
-
140
147
>>> import pandas as pd
141
148
>>> df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv')
142
-
143
149
>>> # Make increasing candlesticks and customize their color and name
144
150
>>> 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)'))
150
153
>>> # Make decreasing candlesticks and customize their color and name
151
154
>>> 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)'))
157
157
>>> # Initialize the figure
158
158
>>> fig = fig_increasing
159
-
160
159
>>> # Add decreasing data with .extend()
161
160
>>> fig.add_trace(fig_decreasing['data']) # doctest: +SKIP
162
161
>>> fig.show()
163
162
164
163
Example 3: Candlestick chart with datetime objects
165
164
166
165
>>> from plotly.figure_factory import create_candlestick
167
-
168
166
>>> from datetime import datetime
169
-
170
167
>>> # Add data
171
168
>>> open_data = [33.0, 33.3, 33.5, 33.0, 34.1]
172
169
>>> 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
177
174
... datetime(year=2013, month=12, day=10),
178
175
... datetime(year=2014, month=1, day=10),
179
176
... datetime(year=2014, month=2, day=10)]
180
-
181
177
>>> # 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)
184
179
>>> fig.show()
185
180
"""
186
181
if dates is not None :
0 commit comments