mplfinance icon indicating copy to clipboard operation
mplfinance copied to clipboard

Point-and-figure chart function issue

Open sunjar2020 opened this issue 2 years ago • 4 comments

I used the point-and-figure chart function of mplfinance and have two issue. One is that the point-and-figure chart does not strictly follow the 1:1 ratio to draw each cell, that is, we can think of the canvas as a grid of countless 1:1 squares, and each X or O appears in the grid in order, no matter if it is enlarged or reduced our chart, this ratio is no change. The purpose of this is that the point-and-figure chart has an important technology called the “45-degree trend line”. We can use it to judge the later trend. If the point-and-figure chart is not drawn to scale, for example, there is a certain distance between the two columns, then the “45-degree trend line” loses its meaning.

The second issue is could the mplfinance can add a function, that is, the lines of every 5 rows and every 5 columns are thickened, just like the real graphics drawn on paper.

Thanks a lot for nice work of mplfinance.

Point-and-figure on paper sample:

http://www.forexalchemy.com/wp-content/uploads/2015/04/point-and-figure-chart.jpg

sunjar2020 avatar Oct 08 '21 02:10 sunjar2020

Thanks for your comments. Will look into this. Regarding the first part, its not clear to me how this may be accomplished in any plotting system that allows the user to change the aspect ratio of the entire canvas by interacting with the plot. (I imagine that the package would have to correspondingly modify the aspect ratio of the Xs and Os to compensate?) We could certainly make PnF charts default to an aspect ratio of 1:1 (but not sure what we can do if the user changes that). Do you have an example of a plotting package or web site that does this: allows the user to change the overall plot aspect ratio and still maintain X and O to appear on the grid in a way that will support the "45-degree trend line”? Or if you can suggest a solution I am open to hearing it.

Regarding the grid lines, and darkening some lines (major vs minor). You may be able to do this yourself now, as a workaround, using the rc= kwarg of mpf.make_mpf_style() (see bottom of the styles tutorial) by appropriately modifying some of the rcparams (for example, axes.grid, axes.grid.which, grid.linestyle, grid.linewidth). Alternatively you can use returnfig=True when calling mpf.plot() and then use the returned Axes objects to call the appropriate matplotlib methods to do this manually. In the meantime, I will definitely consider ways to make this a simple boolean kwarg for the PnF charts and do it automatically for the user. Seems a very reasonable request.

Thanks. All the best. --Daniel

DanielGoldfarb avatar Oct 08 '21 11:10 DanielGoldfarb

Hi, Daniel, thank you for your reply. Regarding the first part, I have no solution. I am new to programming with matplotlib, so I use various third-party plotting libraries. But I found few webpages through searching. I wonder if it is useful to you?

The first two pages is a discussion on stackoverflow, the address is:

The second web page is another third-party drawing library called pyecharts. I have used it to make some charts. I found that when it generates a 3D Bar histogram, it can maintain the original proportions no matter how zoomed, of course its charts exists in a generated HTML file.

Regarding the second point, I will try the method you mentioned. If there is an easier way to turn on the grid function with thickened line on every 5 rows / 5 columns , it will be more perfect. Of course this is not a very imperative function.

I'm sorry that only post requirement and didn't help much, because I am a novice in using python to make graphs. Thank you again for your help and work.

sunjar2020 avatar Oct 09 '21 05:10 sunjar2020

@sunjar2020 Thanks for the links. Don't have much time now, but I took a quick look and I think they will be helpful.

Regarding the method of handling gridlines that I outlined, I will try to find time this week to code something up and, if so, I will post the code example here.

DanielGoldfarb avatar Oct 10 '21 00:10 DanielGoldfarb

No problem and take your time, thanks for everything of mplfinance.

sunjar2020 avatar Oct 10 '21 11:10 sunjar2020