Skip to content

Feature Request: Allow plotting on the existing AXIS #209

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
joeatbayes opened this issue Jul 5, 2020 · 6 comments
Closed

Feature Request: Allow plotting on the existing AXIS #209

joeatbayes opened this issue Jul 5, 2020 · 6 comments
Labels
enhancement New feature or request released code merged into repo AND released to Pypi

Comments

@joeatbayes
Copy link

My existing plots directly use matPlotLib I want to add candle sticks to those graphs not have the candle stick take over. In the old api at mpl_finance it worked great I just passed in the axis of my existing work. You really should support the old strategy. I will just use the deprecated version until you do.

The old API Allowed:
fig = plt.figure(figsize=(14, 10))
ax = plt.gca() # Get current axis
from mpl_finance import candlestick_ohlc
candlestick_ohlc(ax, myBarData)

And it would would just add it's drawing to the existing graph.
The new version requires creating a panda data frame converting
the datetime from string to panda index and then it created a
entirely new figure popping up in a different window. I already
had my X axis labels they way I wanted them so you should not
render them.

@joeatbayes joeatbayes added the enhancement New feature or request label Jul 5, 2020
@DanielGoldfarb
Copy link
Collaborator

Joe,

This is currently in development. I hope to have it ready within the next 2 to 3 weeks.

For more details, see The Matplotlib Method under Subplots in mplfinance

All the best. --Daniel

@joeatbayes
Copy link
Author

Perfect.

@mac133k
Copy link

mac133k commented Jul 16, 2020

Hi Guys,

What do you think about the idea, that the plot functions take matplotlib's fig and ax as parameters, and can also create new instances of those, so then it is possible to easily mix them in with more complex layouts. What I mean is:

def plot(..., fig=None, ax=None):
    if not fig and not ax:
        fig, ax = plt.subplots()
    
    # make the drawing
    ...
    return fig, ax

Then if you need just a single plot you call a function as usual and do not care about anything else, but when you need it as one of the subplots:

fig, axs = plt.subplots(3, sharex=True, ...)
mpl.plot(daily, type='candle', fig=fig, ax=axs[0]
axs[1].plot(something)
axs[2].plot(something_else)

This would provide more flexibility for embedding mpl plots into complex custom layouts and make use of the existing matplotlib functionalities without the need of wrapping.

Regards,
MS.

@DanielGoldfarb
Copy link
Collaborator

@mac133k
That's almost exactly what is currently being developed, as mentioned above.

Did you read this link from the comment above?

Also, for a long time now you can set returnfig=True when calling mpf.plot() and mplfinance will return the Figure and List of Axes it created, to allow you to further do what you want with them. Did you see that?

@mac133k
Copy link

mac133k commented Jul 16, 2020

All right, that's cool. I didn't know about returnfig.

@DanielGoldfarb
Copy link
Collaborator

External Axes Mode is now available.

@DanielGoldfarb DanielGoldfarb added released code merged into repo AND released to Pypi and removed in progress labels Aug 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request released code merged into repo AND released to Pypi
Projects
None yet
Development

No branches or pull requests

3 participants