You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi!
First of all, thank you for such useful library for plotting candles!
I'm trying to process a scenario, when addplot and alines is empty (at the present moment buys and sells lists have only one point in format ['date','price'], but it doesn't matter for question). So my function, that builds a graph is:
defmplfplotcoin(df,title,
buys=[],
sells=[],
rsi=False):
adp= []
# adding tradesifbuys:
buysdf=pd.DataFrame([buys],columns=['Date', 'OpenPrice']) # when buys list consists of one pointbuysdf=df.merge(buysdf,on='Date',how='left')['OpenPrice'] # left joinaddbuys=mpf.make_addplot(buysdf,scatter=True,markersize=300,marker=6,color='forestgreen',alpha=0.75) # buy markersadp.append(addbuys)
ifsells:
sellsdf=pd.DataFrame([sells], columns=['Date', 'ClosePrice']) # when sells list consists of one pointsellsdf=df.merge(sellsdf,on='Date',how='left')['ClosePrice'] # left joinaddsells=mpf.make_addplot(sellsdf,scatter=True,markersize=300,marker=7,color='firebrick',alpha=0.75) # sell markersadp.append(addsells)
# adding line between trades https://github.com/matplotlib/mplfinance/blob/master/examples/using_lines.ipynbiflen(buys) ==len(sells) andbuys: # I know it's awful))) I'll change it latertradeline=dict(alines=[tuple(buys),tuple(sells)],colors='lightslategray',linestyle='--',linewidths=2,alpha=0.5)
else: tradeline=None# adding rsiifrsi:
addrsi=mpf.make_addplot((df['rsi']),panel=1,type='line',color='orange',width=1,ylabel='rsi',ylim=(-5,105))
adp.append(addrsi)
# checking adp listifnotadp: adp=None# drawingmpf.plot(df,
type='candle',
style='tradingview',
volume=True,
show_nontrading=True,
addplot=adp,
alines=tradeline,
figscale=1.3,
title=title,
ylabel='USDT')
so, lines else: tradeline = None and if not adp: adp = None are like this, because I found it in your library file plottin.py:
#211 line:'addplot' : { 'Default' : None,
'Description' : 'addplot object or sequence of addplot objects (from `mpf.make_addplot()`)',
'Validator' : lambdavalue: isinstance(value,dict) or (isinstance(value,list) andall([isinstance(d,dict) fordinvalue])) },
# 267 line:'alines' : { 'Default' : None,
'Description' : 'Draw one or more ARBITRARY LINES anywhere on the plot, by'+' specifying a sequence of two or more date/price pairs, or by'+' specifying a sequence of sequences of two or more date/price pairs.'+' May also be a dict with key `alines` (as date/price pairs described above),'+' plus one or more of the following keys:'+' `colors`, `linestyle`, `linewidths`, `alpha`.',
however I get errors for mpf.plot(..., addplot=adp, alines=tradeline, ...):
If I go to plotting.py, I can't understand why error is rised, because there is only one if about addplot is None:
# 739 lineaddplot=config['addplot']
ifaddplotisnotNoneandptypenotinVALID_PMOVE_TYPES:
...
# and then 816 line is new condition:# fill_between is NOT supported for external_axes_mode# (caller can easily call ax.fill_between() themselves).ifconfig['fill_between'] isnotNoneandnotexternal_axes_mode:
...
Hi!
First of all, thank you for such useful library for plotting candles!
I'm trying to process a scenario, when
addplot
andalines
is empty (at the present momentbuys
andsells
lists have only one point in format['date','price']
, but it doesn't matter for question). So my function, that builds a graph is:so, lines
else: tradeline = None
andif not adp: adp = None
are like this, because I found it in your library fileplottin.py
:however I get errors for
mpf.plot(..., addplot=adp, alines=tradeline, ...)
:and the same for
alines
parameter:If I go to
plotting.py
, I can't understand why error is rised, because there is only oneif
aboutaddplot is None
:Ok, I tried to define
ptype
in my code:But again error:
Please, help me to understand how to draw plot if
addplot
andalines
(and other kwards) are empty?The text was updated successfully, but these errors were encountered: