Skip to content

Is it possible to reduce the left margin on the candle chart? #392

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
piiq opened this issue May 15, 2021 · 2 comments
Closed

Is it possible to reduce the left margin on the candle chart? #392

piiq opened this issue May 15, 2021 · 2 comments
Labels
question Further information is requested

Comments

@piiq
Copy link

piiq commented May 15, 2021

Hi 👋,
Thanks for this nice tool. It really saves time doing routine things.

I ran into an issue with the candle chart. When I plot this chart using a qt backend there are some margins on the left and right. The one on the left is particularly annoying because it takes considerable amount of space even if I enable tight layout.

Here's how it looks with wight layout on
image

And here's how it looks with regular layout
image

Here's the code that generates the chart

mc = mpf.make_marketcolors(
    up="green", down="red", edge="black", wick="black", volume="in", ohlc="i"
)

s = mpf.make_mpf_style(marketcolors=mc, gridstyle=":", y_on_right=False)

ap0 = []

if "OC_High_trend" in df_stock.columns:
    ap0.append(
        mpf.make_addplot(df_stock["OC_High_trend"], color="g"),
    )

if "OC_Low_trend" in df_stock.columns:
    ap0.append(
        mpf.make_addplot(df_stock["OC_Low_trend"], color="b"),
    )

fig, axlist = mpf.plot(
    df_stock,
    type="candle",
    mav=(20, 50),
    volume=True,
    title=f"\n{s_ticker} - Last 6 months",
    addplot=ap0,
    xrotation=10,
    style=s,
    figratio=(13, 7),
    figscale=1.10,
    figsize=(plot_autoscale()),
    update_width_config=dict(
        candle_linewidth=1.0, candle_width=0.8, volume_linewidth=1.0
    ),
    # tight_layout=True,
    returnfig=True
)
canvas = FigureCanvas(fig)

I've tried to go with subplot_adjust, but this wasn't the right direction...

Is there a way to make the plot take up more width, and most important is there a way to get rid of the annoying margin on the left?

@piiq piiq added the question Further information is requested label May 15, 2021
@DanielGoldfarb
Copy link
Collaborator

@piiq
Copy link
Author

piiq commented May 16, 2021

How could I miss that discussion =)
Thanks @DanielGoldfarb worked perfectly.
image

@piiq piiq closed this as completed May 16, 2021
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