-
Notifications
You must be signed in to change notification settings - Fork 654
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
Implement y-scale (ex: log) #21
Comments
+1 |
Philipp- Thanks for your words of appreciation. Regarding "setting chart titles and legends" ... Chart title and axis titles are part of a large set of enhancements that I hope to release by the end of this week, or early next week. Legends perhaps the next release after that. Regarding changing y-scale and/or x-ticks, can you please provide an example where you would find it desireable to do this, either code, or screen shots with and without these abilities, or screen shots with a description of how you would make it appear if these abilities were available in Regarding help, as mentioned I am at the tail end (testing and final tweaks) of a relatively large set of enhancements, with some restructuring of the code, but after that, help will be definitely appreciated. In the meantime, if you have time, please take a look at my comments on this issue to get some feel for the philosophy behind the new api and why some functionality is limited. I am certainly open to discussion about how to provide the best balance between detailed control over matplotlib "primitives" and an easy-to-use higher-level interface that allows users to focus mostly on their own analysis of financial markets. Greater flexibility often means more complex code, and it is important to me to implement things in a way that keeps the code easily maintainable, while still providing a significant amount of "automatic" stuff to keep things simple for the average user. That said, with the project's priorities in mind, nothing is out of the question. |
@starovp Philipp- Thanks for taking the time to explain clearly what you want. That is definitly reasonable, and should be relatively easy to implement as you have indicated, or in a somewhat similar way. I say "or in a somewhat similar way" because with the next release, there will be four Y-axes available (two panels: main and lower, and a primary and secondary Y-axis for each). So we would just have to have a way to indicate which of the four y-axis you want to scale differently. Thanks. |
|
Hi Daniel, thank you very much for your work! I just started to plot candle sticks using this new library and I find it amazing! To add on to what OP @starovp request about modifying x-ticks, I personally find it useful to have some level of control over the x-ticks. For example, in the following 5 mins intraday candlestick chart, I would like to maybe include more x-ticks in the chart, I probably want the x-ticks to include the start of every hour for convenience. And I may also want to rotate the x-ticks to 90 degree if there are too many x-ticks in the x-axis. In the current plot (see below), there are only 5 x-ticks and they do not align well with the start of a new hour. Again, what your currently have for us is already amazing. This x-axis control is just another nice feature to have. Thanks again for your work! I really like this library! Thanks, ZG |
ZG- Thanks for participating in the discussion, and I especially appreciate that you provided a specific example; it is definitely helpful to have a particular use-case for understanding the need or desire for a feature. Allowing rotation of the axis labels is trivial; can do that. Presently it is hard-coded to 45 degress. We can make that the default and create a kwarg for it. Regarding placement of the ticks, the issue is this: The default (based on some comments/requests from people) for In matplotlib, as far as I know, there is only one practical way to implement a feature similar to The way we implemented that is by setting the actual x-axis values to a simple range of integers, equal in length to the number of data points. Then we give matplotlib a special x-axis formatting function which effectively maps the integer to a specific date. (You can see the code here). I am not very experienced with customizing tick placement, so I don't know, would have to investigate, if it is possible to create a similar mapping function for determination of x-tick locations. Doing that, it seems to me, would be needed in order to have ticks on 5 minute boundaries, or every Monday, etc., when the actual x-axis values are a simple range of integers. (If you are comfortable enough with Python and Matplotlib, perhaps you can investigate; I don't think I would get to it for several weeks or months; trying to get some other enhancements out). Alternatively, and I'm a little reluctant to do this because it is a bit kludgy, we could maybe allow manipulation of the x-ticks if and only if the caller sets (When there are no non-trading periods, then the plot looks the same for Finally, on a separate topic, I would like to confirm if the image you posted here was indeed created with Thanks. All the best. --Daniel |
Hi Daniel: For your other comments, I will try to put in my 2 cents.
The rotation is only needed when we have a few more x-tick labels along the x-axis and when the x-axis becomes crowded. But if it is easy to implement, it would be nice to have as well.
I think this makes a lot of sense.
I personally do not like this idea as well. Because who knows maybe one day I would like to include 3 days worth of intraday data in one single plot. For your paragraph 4 and 5 about the implementation logic, I wish I know more about matplotlib to fully understand your reasoning. I am really sorry but I do not fully understand why the xticks function is not working here. As for the image, yes, it was plotted using mplfinance. I just started to learn about mplfinance yesterday and that image was the first few images I plotted using mplfinance. This package is easy to use and there is no learning curve at all. It really saved my time! It is not the best looking imagine I have plotted using mplfinance. Please give me a few more days and I promise I will provide a better looking image to you. Again, thank you very much for your work! Appreciate it! Thanks, |
Note for anyone that want to change the y-scale into log and want to use non-scientific notation, you also need to set the minor formatter import mplfinance as mpf
import matplotlib.ticker as ticker
fig, axlist = mpf.plot(..., returnfig=True)
ax1 = axlist[0]
ax1.set_yscale('log')
ax1.yaxis.set_major_formatter(ticker.FuncFormatter(format_price))
ax1.yaxis.set_minor_formatter(ticker.FuncFormatter(format_price)) |
legends will be on a separate issue. this issue for tracking |
@char101 What I have in mind is adding two kwargs:
Also, ideally it should be possible to pass either or both of the two kwargs Please let me know if making this enhancement is interesting to you. Thank you. All the best. --Daniel |
Hi @DanielGoldfarb , I am sorry but I am not currently using mplfinance at the moment. I end up creating charts from scratch using matplotlib while "borrowing" code from mplfinance, especially the code to create the collections. I choose to create the charts from scratch since I want to try various options not covered by mplfinance. As for Also, using a classname as string like |
Thanks @char101 for the quick response. And for your advice about And thank you again for all of your contributions to discussions in this repository, and for suggestions on improving the code, all of which were very good and helpful. I really appreciate that very much. All the best. --Daniel |
Thank you Daniel for maintaining mplfinance. It is very helpful when we need to create financial charts quickly or when learning how to create it using matplotlib API. |
Hi Daniel, thanks for helping to develop this library. I was wondering if it'll be (or already is) possible to manipulate the resulting charts much like matplotlib charts, for example:
I'd love to be able to do this with the existing charts. Let me know if I can help. Thanks!
The text was updated successfully, but these errors were encountered: