API for adding labels: mpf.make_addplot(..., label="myLabel") by alexpvpmindustry · Pull Request #605 · matplotlib/mplfinance (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation17 Commits12 Checks0 Files changed

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

alexpvpmindustry

easy api for adding labels to mpf.make_addplot

image

Note:

see examples/addplot_legends.ipynb for the example notebook.

courtesy of @ppseverin for inspiration, replacing PR #277

@alexpvpmindustry

@DanielGoldfarb

@alexpvpmindustry
Alex,
Just took a quick look. Beautiful job. I'm really swamped right now, but will do my best to set aside some time early next week (Monday or Tuesday) to fully test and then merge. In the meantime, please bump the version.
My mind is wondering (what do you think) should we rename the kwarg to legend_label to be more explicit (since there are also xlabel and ylabel and an annotation can have a label)? Or do you think it's self-explanatory as is?
All the best. --Daniel

@alexpvpmindustry

kwarg to legend_label to be more explicit

I use matplotlib alot, so label would be the first thing I would try.

an annotation can have a label

That is new to me.

Either way, it would be more useful for the doc string to report all the allowed kwargs. Currently if I press shift+tab, the doc that comes out is quite useless.

some time early next week (Monday or Tuesday)

No worries mate, no rush on my side. Just happy to contribute

@alexpvpmindustry

@DanielGoldfarb

If you think 'label' is more intuitive for a matplotlib user that's ok. I know many of the matplotlib functions accept kwarg label meaning the label for the legend. Meanwhile, if you google "matplotlib label" most of the top results are about labeling the x and y axis. I don't feel strongly about this, but i do also want to be clear to users who may not be familiar with matplotlib. Part of my mplfinance philosophy is to make it easy to use without knowing matplotlib (or much python) while at the same time having hooks in place for those who know matplotlib and want to access it's full power.

Regarding doc strings, the is a method you can call, mpf.kwarg_help() which will output information about the kwargs (from the valid kwargs table). Perhaps I will add info about the kwarg_help() function to all of the doc strings.

@alexpvpmindustry

without knowing matplotlib (or much python)

sidenote: is there a way to provide kwargs suggestion/correction? like if someone input the wrong kwargs, the error at the end should say "ledgend_label" does not exist, do you mean "legend_label"? or something similar. in the docs of numpy functions, there is usually a suggestion for similar/related functions.

mpf.kwarg_help()

that is new to me :D

I will add info about the kwarg_help()

maybe u can put it into a todo.

@alexpvpmindustry

also, not sure if its somewhat related.
i think there should also be labels for mavs. maybe automatically generated or have the option to toggle it on or off or specify a list of strings.
but i realised mav was implemented all over the place, so might be a lot more difficult than doing legend_labels for make_addplot

@alexpvpmindustry

@DanielGoldfarb

Will try to look at this next week or the week after that.

@DrChandrakant

@DanielGoldfarb
i successfully attempted 'legend_label ' add add_plot

legend

legend 2

Following Merge PR Work Improve and creating New PR request Soon, any Suggestion for the new feature?

Script additions for 'ema' plotting #563

API for adding labels: mpf.make_addplot(..., label="myLabel") #605

@dempc6469

checking in on the labes piece here. Any update?

@DrChandrakant

@dempc6469

@DanielGoldfarb

@dempc6469 (et al)
I have a lot of mplfinance PRs to review. Unfortunately, this week, due to other pressing projects, I won't get to any of them. However I expect to begin reviewing mplfinance PRs again next week.

In the meantime if you do try out @DrChandrakant 's version I will greatly appreciate it if you can please post any feedback here. Thank you very much!

rudradesai200

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried this out and it works well. Can someone please merge this PR?

@DrChandrakant

I tried this out and it works well. Can someone please merge this PR?

I think the moderator is busy with other projects please download this and use link here alexpvpmindustry:master

@DanielGoldfarb

Thanks to those who have tried this out!
I am hoping to get back to processing the backlog of PRs sometime next week.

@DanielGoldfarb

@DanielGoldfarb

@DanielGoldfarb

I've tweaked the code so that when passing a DataFrame to make_addplot() then it is possible to set label to a sequence of labels and each one will be used in order for each column of the dataframe that is plotted.

NEXT I need to test this new code for all relevant make_addplot() (i.e. line, bar, scatter) and also modify the addplot_legends.ipynb to have an example of doing this (as well as remove the part that suggest using multiple make_addplots instead).

I hope to finish this today or tomorrow.

@DanielGoldfarb

@DanielGoldfarb

@DanielGoldfarb