-
Notifications
You must be signed in to change notification settings - Fork 657
Bug Report: Unnecessary graphs are displayed when add_subplot is done in mpf.figure() #241
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
Comments
If you want to use "External Axes" mode, then you have to pass your Axes in to This line: ax = mpf.plot(df[1000:], figratio=(16, 9), type='candle', volume=True, mav=(5, 25), style=style) should be: mpf.plot(df[1000:], figratio=(16, 9), type='candle', volume=True, mav=(5, 25), style=style, ax=ax) Even doing that, keep in mind the following so that you can understand the results you will get: You are creating a Figure with one style, and each of your Axes with other styles, which creates effectively a mixed style which in some cases may have incompatibilities between the styles. More specifically, since you are not passing any style when creating the Figure with You can see an example of getting around one specific incompatibility in the External Axes notebook in Cells The specific incompatibility, in this external axes example, is that style HTH. Let me know if you have any further questions. All the best. --Daniel |
@daniel Thanks for the confirmation. Corrected code:. fig = mpf.figure(figsize=(12,36))
for i, style in zip(np.arange(1, 13), g_style):
ax = fig.add_subplot(6, 2, i, style=style)
mpf.plot(df[1000:], type='candle', mav=(5, 25), axtitle=style, ax=ax, xrotation=15)
mpf.show() What my code can't achieve.
How to deal with it:.
I support further upgrades. Thanks. |
I strongly recommend that you go carefully through all of the tutorials, and pay particular attention to those under As I already mentioned above, if you mix incompatible styles (one style for the Figure and one style for the Axes) the you will get undesireable results. In your example above with 'nightclouds' and 'mike', you have two choices: you can either customize 'nightclouds', and 'mike' to have non-white text, or customized the style used for the Figure itself, so that the Figure background is perhaps a color that will contrast with both black text and white text; then you will be able to view all of the pre-packaged Axes styles on a single Figure (even though the Figure is not the same as it would be for each style alone). Regarding passing in an Axes for volume. There is an example in cells [6] and [7] of the external axes notebook I would also strongly discourage you from using external axes mode. As stated in the description of external axes mode,
The intention of External Axes mode is to give those who already have a strong understanding and skill level with Matplotlib itself, the ability to use those skills fo to go beyond what mplfinance can do. But mplfinance can already do a lot, and I suggest you first learn everything that it can do without external axes mode, which is already 90% to 95% of typical plots you would expect to see in the financial markets. Thanks. All the best. --Daniel |
For what it's worth, here is an example of using a Figure color that contrasts nicely with both black text and with white text: fig_style = mpf.make_mpf_style(base_mpf_style='default',figcolor='#3C8284')
fig = mpf.figure(figsize=(12,36),style=fig_style)
for i, style in zip(range(1, 13), g_style):
ax = fig.add_subplot(6, 2, i, style=style)
mpf.plot(df, type='candle', mav=(5, 25), axtitle=style, ax=ax, xrotation=15)
mpf.show() The only problem with doing it this way is that, in practice, none of these styles actually have #3C8284 as their Figure background color. But it does help see all styles from the Axes perspective. The result: |
@DanielGoldfarb |
New handling of volume exponent; and assorted scratch_pad additions: This PR is primarily to implement a new way to handle the volume exponent; the new way avoids calling `.draw()` which in turn eliminates the bug mentioned in issue #296, and also mentioned/described in a previous email from S.G. ([commit 2c88663](2c88663)) This PR also includes a lot of scratch_pad work for investigations of various issues (#282, #236, #241), and for an mplfinance presentation: including comparison of old and new api's, intraday animation with volumes, generation of animation gifs, etc.
Describe the bug
I wanted to create a list of styles that can be applied to the graph, so I tried the new subplot feature and the completely unrelated graphs are displayed first. After that, the desired graph is displayed normally.
To Reproduce
When you run the following code, the
Some of the data used are presented below.
Screenshots

Desktop (please complete the following information):
This is a bug report, but my code may be wrong, and if so, please point it out to me.
The text was updated successfully, but these errors were encountered: