Skip to content
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

how to extend the y-axis? #598

Open
DonSeger opened this issue Mar 13, 2023 · 4 comments
Open

how to extend the y-axis? #598

DonSeger opened this issue Mar 13, 2023 · 4 comments
Labels
question Further information is requested

Comments

@DonSeger
Copy link

DonSeger commented Mar 13, 2023

Perhaps the best way to explain this problem is by the picture below. As you can see, there are three blue lines drawn, but the top line is out of plot. How can I extend the y-axis on the graph so that the top line is fully visible?

mpf-problem margins

This code below created the plot:

fig, axlist = mpf.plot(data[start_date:end_date], figratio=(20,12),
    type='candle',
    alines=seq_of_seq_of_points,
    volume=True,
    tight_layout=True,
    style='yahoo',
    addplot=apd,
    returnfig=True)

fig.suptitle("SPY", y=1.05, fontsize=30, x=0.59)
@DonSeger DonSeger added the question Further information is requested label Mar 13, 2023
@DanielGoldfarb
Copy link
Collaborator

DanielGoldfarb commented Mar 13, 2023

You can use kwarg ylim to extend the y-axis, for example ylim=(120,170).

Also, from what I can see, there is no reason to use returnfig=True; rather you can pass a dict into kwarg title, thus:

mpf.plot( data[start_date:end_date], 
    figratio=(20,12),
    type='candle',
    alines=seq_of_seq_of_points,
    volume=True,
    tight_layout=True,
    style='yahoo',
    addplot=apd,
    title=dict(title="SPY",y=1.05,fontsize=30,x=0.59),
    ylim=(120,170) )

@DonSeger
Copy link
Author

There is something else that is very strange. As you can see in the chart above, the year is present on the x-axis as part of the date. But when I plotted another plot with the same lines of codes as above, the yeas was suddenly missing from the datetime on the x-axis, as you can see in the picture below. How can the year be made visible again?

year problem

@DanielGoldfarb
Copy link
Collaborator

By default, mplfinance only displays the year if your data crosses one or more December to January boundaries. This feature is part of mplfinance's "automatic" formatting of the axis, which also includes things such as displaying the time as well, if the data appears to be intraday data.

You can override the "automatic" formatting of the x-axis with the datetime_format kwarg.
For examples of using this kwarg, see cell In [8] in the plot customizations tutorial.

For the full set of available formats, see strftime.org.

@DrChandrakant
Copy link
Contributor

There is something else that is very strange. As you can see in the chart above, the year is present on the x-axis as part of the date. But when I plotted another plot with the same lines of codes as above, the yeas was suddenly missing from the datetime on the x-axis, as you can see in the picture below. How can the year be made visible again?

year problem

  1. Use Pandas To Find the Max High Present In the dataframe.
  2. Add % Value to Max
  3. Set it as ylim

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

3 participants