Skip to content

how to control the lines size when add Own Technical and add legend? #221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cvJie opened this issue Jul 19, 2020 · 3 comments
Closed

how to control the lines size when add Own Technical and add legend? #221

cvJie opened this issue Jul 19, 2020 · 3 comments
Labels
question Further information is requested

Comments

@cvJie
Copy link

cvJie commented Jul 19, 2020

hi,Daniel:

       I use the mpf.make_addplot add my own Technical(MA55,MA200,....),but the line too large, I need to shrink it .

At the moment,I need add the legend based on different color to different lines.

can you give my some advices?

thanks

@cvJie cvJie added the question Further information is requested label Jul 19, 2020
@DanielGoldfarb
Copy link
Collaborator

DanielGoldfarb commented Jul 19, 2020

  • First, please make sure you have the latest version of mplfinance (pip install --upgrade mplfinance) as the algorithm for adjusting widths has changed a couple of times.
  • Second, please note that mpf.make_addplot() has a width= kwarg that can be used to adjust line widths (or bar widths for bar charts). There is also a linestyle= kwarg to make_addplot() which may be useful for you (see https://matplotlib.org/3.1.0/gallery/lines_bars_and_markers/linestyles.html).
  • If the width is still an issue after the above, read carefully through this entire tutorial. In particular, for what you described, you may need to adjust Item: 'lines', Keyword: 'line_width', however I recommend first trying some of the simpler approaches suggested in that notebook.

Please let me know how that works out for you. Thank you. --Daniel

@cvJie
Copy link
Author

cvJie commented Jul 20, 2020

  • First, please make sure you have the latest version of mplfinance (pip install --upgrade mplfinance) as the algorithm for adjusting widths has changed a couple of times.
  • Second, please note that mpf.make_addplot() has a width= kwarg that can be used to adjust line widths (or bar widths for bar charts). There is also a linestyle= kwarg to make_addplot() which may be useful for you (see https://matplotlib.org/3.1.0/gallery/lines_bars_and_markers/linestyles.html).
  • If the width is still an issue after the above, read carefully through this entire tutorial. In particular, for what you described, you may need to adjust Item: 'lines', Keyword: 'line_width', however I recommend first trying some of the simpler approaches suggested in that notebook.

Please let me know how that works out for you. Thank you. --Daniel

thanks ,Daniel
I used the width solve my trouble,code as:mpf.make_addplot(tech_index_dataframe,type='line',width=0.01);
but I don't know how to add legend ?
and I find the url:#181 answer:Legends are not yet available in mplfinance;

Can it be solved now?
thanks

@DanielGoldfarb
Copy link
Collaborator

@cvJie
At this point in time, the only way I can think to do legends is to use mpf.plot(...,returnfig=True,...) to get back the Figure and Axes, and then somehow use https://matplotlib.org/api/_as_gen/matplotlib.axes.Axes.legend.html to create a legend and the call plt.show(). (You need to call plt.show() because when returnfig=True then mpf.plot() will not call show().)

I've never done this creating legends myself, so I don't know if I can be more help other than suggesting this approach.

At some point mplfinance will support legends more directly, but unless someone else wants to work on it, I myself am probably not going to have time to work on it for a while.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants