Y=1.1, are for buttons’ position and alignment in the plot. I don’t have much to say about type="buttons" and direction="left", I won’t go in too deep explaining why the function accept parameters this way.īut I want you to have an overall grasp on the configurations. """ if resample_config is None : resample_config = ]) for idx, text in enumerate ( text_list ) ], ) ] ) Import pandas as pd def resample_k_lines ( data, resample_config = None ): """ Below we define a function named resample_k_lines. Using pandas.resample function, we could easily do some resampling. resample the dataĪ common practice for k-lines manipulations is to resample the daily data into weekly or monthly data. In this part, we will introduce how to add buttons to update the layout of the plot, which is in plain English by clicking one of the buttons you may be able to transform your plot of daily k-lines into a redrawn monthly k-lines. Add buttons to the plot to produce different k-lines plot For the full documentation of this function, please refer to this link. The first step we need to conduct is to generate resampled data for the plot purpose. And we may also want to make the plot even more elegant to the original one provided by eastmoney, a Chinese giant financial company.Īnd Below is the final plot we would have by the end of this tutorial, if you are lucky. What if we want to plot the k-lines of 5-days or 1-month and switch among those plots interactively by clicking some buttonsĪs shown in the picture below. Since it could only exhibit a basic daily k-lines plot and the x range bar is too tall for a secondary/controlling part of a plot. You may have noticed the plot is quite rough, I have created a repository named sample_plot hosting a basic daily k-line plot,Īnd by clicking the link you may be automatically redirected to the site. In this tutorial, we will continue to dive into the world of plotly, a powerful toolkit that enables us to produce vividįirst, let’s recall what we have achieved in the last tutorial. So I hope the people who read this tutorial will not struggle to button-or- layout-related problems when plotting k-lines. We know that adjusting and choosing among several parameters’ combinations is a tedious and time-consuming work. This tutorial is modified based on my repository customize-financial-plotly-plot and focuses on further beautifying and adding more functionalities into the plotly plot created in the last tutorial for my wife.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |