Comments (6)
At present there is no direct way to do this. You can try using a custom style and setting an appropriate rcParam, for example:
s = mpf.make_mpf_style(base_mpf_style='yahoo', rc={'font.size':20})
mpf.plot(data,figscale=2.0,style=s)
Let me know if that helps.
from mplfinance.
I'm wondering if the figscale=
kwarg should also scale fonts along with the figure size. Let me know what you think.
(Although when I made a very large figure, although the fonts did not scale accordingly, I did not find in my use-case, and in my environment, that they were really small for the larger charts.)
from mplfinance.
@DanielGoldfarb The custom style method you suggested worked very well. Thank you!
And I think it would be very convenient if the font size could scale automatically.
from mplfinance.
Firstly thanks for your work on mplfinance - i've only just discovered it and am loving its approach so far vs other libraries i've used.
I wanted to ask about your solution above using rcParams. Are all original matplotlib rcParams available to be used here?
I found a list on https://matplotlib.org/3.1.1/tutorials/introductory/customizing.html that i used to experiment and am not sure whether they are not supported by mplfinance or whether i am calling them incorrectly.
For example i tried unsuccessful to alter your solution above to instead change the number format on the x-axis:
s = mpf.make_mpf_style(base_mpf_style='yahoo', rc={'date.autoformatter.day':'%d-%m-%Y'})
mpf.plot(data,figscale=2.0,style=s)
Lastly i would be keen to contribute to this package where my limited knowledge is able to. I have created a notebook of examples i have created so far whilst experimenting that i could add to your examples if interested. Otherwise please reach out in the future if there's anything simple you can delegate.
Kind regards
Cam
from mplfinance.
@cammclean182
Cam,
Thanks so much for expressing your appreciation and for getting involved. Regarding rcParams, yes all are available, but there are two caveats to keep in mind:
mpf.plot()
uses matplotlib's rcParams context manager, effectively creating it's own internal rcParams from the existing global rcParams). Therefore (as you did) you should pass rcParams changes into the API via thestyle
kwarg. Then, because of the context manager, you will not see those changes in the global rcParams, but they will affectmpf.plot()
.- The use of the context manager for rcParams inside of
mpf.plot()
was removed 2020-MAY-13 due to popular demand. Thusmpf.plot()
does use the global rcParams, although it re-initializes rcParams by callingplt.style.use('default')
before any mpf style is applied. - Users can externally apply matplotlib's rcParams context manager if desired. It is also possible to circumvent mplfinance's reinitialization of rcParams, by making a copy of rcParams and passing it into
make_mpfstyle()
using therc=
kwarg, for example:mpf.make_mpfstyle(...,rc=my_rcParamsCopy,...)
- Note: the reason for the re-initialization of rcParams is to ensure that a given mpf style will appear the same for all users. Using the above circumvention method ensures that it is obvious that the user is creating their own custom style and thus there is no question of a particular style appearing different for different users.
- The use of the context manager for rcParams inside of
- Throughout matplotlib, rcParams is used for default values. Whenever a value is passed explicitly into matplotlib's APIs, the explicit value is used instead of rcParams.
Your question has highlighted the fact that I need to do a better job of documenting which parameters are explicitly controlled by mplfinance
. Some are documented in the table near the bottom of the customization examples notebook where it states "Note that the following kwargs also modify rcParams: facecolor, figcolor, gridcolor, gridstyle, gridaxis; If any of them are specified, and the same rcParam is also specified, then the kwarg takes precedence.
"
I realize now that I need to document other "overrides" that mplfinance is routinely doing, for example formatting the DateTime axis labels. The ability to not display non-trading days requires that mplfinance explicitly control the DateTime formatting (and not rely on rcParams).
The solution is this: we need to create a datetime_format
kwarg, and tie it's value into mplfinance's explicit control of the formatting. I think this should be relatively easy. The code where mplfinance determines the format is here. If you are comfortable with it, you could add the kwarg to the valid kwargs table with a default value of None, and then use it (if it is not None) in place of the existing logic.
I would definitely be interested in seeing your examples. You can place them in a repository or gist, and either make it public or give me permission to collaborate so I can see them, or if you prefer email me at [email protected] Alternatively you can fork mplfinance, and stick your examples in the examples directory, or perhaps the examples/scratch_pad directory, where I can review them in your fork and let you know if we want to add them to this repository. (I also may ask you if I can use them in a talk at a Python conference. I have submitted a proposal to speak on mplfinance at three different Python conferences this year, and I would love to be able to show examples from other mplfinance users; not just my own).
from mplfinance.
Although it can make sense to scale the Font size when scaling the Figure, two factors may be an issue:
- Some users of
figscale
may be OK with font sizes as they are now, and if we start changing the font size unexpectedly for those users, they may find it undesirable. - It is very possible that at least some users will find that, while scaling the Font sizes may be desirable, scaling them by the exact same amount as the Figure may not give the best appearance that they want.
Therefore I have decided to implement this as a new kwarg, fontscale
. Users who want fonts scaled by the same amount as the figure can set figscale=
and fontscale=
to the same value. Others can find the mix that they prefer, and/or leave fontscale
untouched.
from mplfinance.
Related Issues (20)
- during save to image file to the disk, there are some noise...how to fix these issue? HOT 2
- Adding ConciseDateFormatter displays dates from 1970 HOT 10
- Bug Report: Is there a typo in src/mplfinance/plotting.py, line 946: fig.suptitle(title,**title_kwargs) HOT 1
- how to get OHLC return values and trend from renko plot HOT 1
- Issue while trying to get_ydata of an EMA from a fig or from the axes HOT 3
- Subplot and panel work fine when they use separately, but mix up when I try to use them in same figure, how can I solve? HOT 8
- Feature Request: HOT 2
- How do i get renko values without ploting the chart? HOT 2
- weird orange line appearing in axes' .plot() HOT 1
- Parabolic Sar and supertrend for renko
- Assist to draw Simple Moving Average. HOT 2
- I just don't know who to ask…. HOT 1
- mplfinance warn if user passes an empty data set. HOT 1
- Feature Request: The line width argument adding request for 'candlestick_ohlc' about the 'Wick/shadow' part(above/blow line) HOT 9
- Bug Report: marketcolors display error when open=close HOT 1
- Bug Report: Typo HOT 1
- How do I create a buy indicator using mplfinance? HOT 1
- Using with `matplotlib.testing.decorators.image_comparison` HOT 6
- PNF ATR Boxsize HOT 4
- Hollow and Filled Candles HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mplfinance.