Comments (11)
At present there is no way to do this. You can sort of fake it out with mpf.make_addplot()
by passing in a list of data (the same length as your dataframe) that is all nan
except for two points (where you want the vertical line). If your data series has a lot of points, it will look like a vertical line. (But if your data series is relatively short, then it will be obvious that the line is on a slight angle ;-)
There is a plan to add two kwargs to mpf.plot()
, vline=
and hline=
For example, for a vertical line you could specify vline=<someTimeStamp>
and you would get a vertical line at that timestamp, or for a horizontal line hline=<somePriceValue>
and you would get a horizontal line at that value. Alternatively you could specify a list of timestamps for vline, and/or a list of values for hline, in order to plot more than one vertical or horizontal line (one line for each value in the list).
If you have a different idea as to how the interface should be, that you think may have an advantage over the vline
and hline
idea, please feel free to describe it here.
If you are interested in coding this vline
and hline
enhancement, I will be happy to guide you through the code. (Otherwise, I am hoping to code it myself maybe sometime in the next 4 to 8 weeks).
from mplfinance.
I've tried this and works perfectly thanks! Can we get it in make_addplot function too so it can be used for indicators in the lower pannel?
from mplfinance.
I'd like to vouch for this enhancement, currently, with my project, I'm using the workaround @DanielGoldfarb describes, but the line doesn't look quite straight sometimes.
from mplfinance.
@DanielGoldfarb Let me know if I can help test or implement something on this.
from mplfinance.
@free-soellingeraj
Aaron,
Thank you very much for offering to contribute. This is almost done. I have vlines
(vertical), hlines
(horizontal), and alines
(arbitrary) working. I am presently developing tlines
(trend), which I expect to finish some time today. If you would like to help test before I enter a PR, you can pick up the code from here. ... and you can see how it works by looking at the following three scratch notebooks:
If you'd rather wait to test in a day (or two, I have some other cleanup to do too) for the PR to be in place, no worries. Up to you. In terms of implementation, if you would like to implement regression tests for this that would also be helpful. Take a look at this test folder and create test_lines.py
(or perhaps there should be a separate file for each: test_vlines.py
, test_hlines.py
, etc. so that the files are more reasonable in size). You can follow the general pattern of what's being done there for other features. Please let me know if any of this is of interest and if you have the time to move forward on any of it.
All the best. --Daniel
from mplfinance.
Sure, I will take a look. I had a need specifically for several of these features. I will let you know.
from mplfinance.
also being able to choose colors could be interesting
from mplfinance.
@Brechard
Rodrigo,
Thanks for the idea regarding make_addplot()
. I've been thinking that ideally mpf.make_addplot()
should support all the same kwargs that mpf.plot()
does. At this point I am not sure if we can support all of them, but certainly some of them should be do-able.
Regarding choosing colors, this is already supported for vlines
, hlines
, etc.
See the documentation here. You can control colors, linestyle, linewidths, and alpha.
All the best. --Daniel
from mplfinance.
Dear @DanielGoldfarb, congratulation for your work, it is very helpful.
I am trying to use horizontal lines with different linestyles, I organize data in a list with price (niveles) and style (estilo).
mpf.plot(TA_data, type='candle', axtitle=(symbol), style='yahoo', ax=ax1, volume=ax2,
xrotation=0, addplot=apds, hlines=dict(hlines=niveles, linewidths=1, colors='k', linestyle=estilo))
but I get next error:
TypeError: kwarg "linestyle" validator returned False for value: "['--', '--', '--', '--', '--', '--', '--']"
'Validator' : lambda value: value is None or value in valid_linestyles },
may you help me? please.
from mplfinance.
@gambitov
mplfinance [hvta]lines
kwargs accept only a single value for linestyle
.
However, it does appear from the code that multiple values (list,tuple) are possible for colors
and for linewidths
. So you may consider using colors=
to differentiate your various hlines
.
Alternatively, as a work-around, you may draw each horizontal line using mpf.make_addplot()
which will allow you to assign a different linestyle to each horizontal line. For example, suppose you want a horizontal lines at values of 185.0 195.0 and 210.0, then, in order to have a different line-type for each line, do the following:
apds = [
mpf.make_addplot( [185.0]*len(TA_data), linestyle='-' ),
mpf.make_addplot( [195.0]*len(TA_data), linestyle='--' ),
mpf.make_addplot( [210.0]*len(TA_data), linestyle='-.' )
]
Given that colors
and linewidths
appear to accept multiple values, it seems a reasonable enahncement request for linestyle
also to accept multiple values. I will have to investigate: It is certainly reasonable to accept a list or tuple for linestyle for hlines
and vlines
(assuming the list is the same length as the number of lines requested), but it may raise complications for tlines
and alines
(if so, then a list or tuple will not be supported for those types of lines).
HTH. All the best. --Daniel
from mplfinance.
Hi @DanielGoldfarb ,
it seems that it fits to my hlines proposal mentioned in #219 a dict of dicts ;-)
hlines = [dict_support_lines, dict_resistence_lines]
Regards, Markus
from mplfinance.
Related Issues (20)
- during save to image file to the disk, there are some noise...how to fix these issue? HOT 2
- Adding ConciseDateFormatter displays dates from 1970 HOT 10
- Bug Report: Is there a typo in src/mplfinance/plotting.py, line 946: fig.suptitle(title,**title_kwargs) HOT 1
- how to get OHLC return values and trend from renko plot HOT 1
- Issue while trying to get_ydata of an EMA from a fig or from the axes HOT 3
- Subplot and panel work fine when they use separately, but mix up when I try to use them in same figure, how can I solve? HOT 8
- Feature Request: HOT 2
- How do i get renko values without ploting the chart? HOT 2
- weird orange line appearing in axes' .plot() HOT 1
- Parabolic Sar and supertrend for renko
- Assist to draw Simple Moving Average. HOT 2
- I just don't know who to ask…. HOT 1
- mplfinance warn if user passes an empty data set. HOT 1
- Feature Request: The line width argument adding request for 'candlestick_ohlc' about the 'Wick/shadow' part(above/blow line) HOT 9
- Bug Report: marketcolors display error when open=close HOT 1
- Bug Report: Typo HOT 1
- How do I create a buy indicator using mplfinance? HOT 1
- Using with `matplotlib.testing.decorators.image_comparison` HOT 6
- PNF ATR Boxsize HOT 4
- Hollow and Filled Candles HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mplfinance.