I want the text to be plotted along with the lines, not as labels. Is there any solution? Thanks.
Posts made by panda0824
Is there any way to plot some custom text in my Indicator?
RE: Plot slicing image with custom indicator in master frame cause unexpected result
Yes, the image matches my problem, as you can see the label 21.28 is far away from the top. subplot=True will plot everything in a new frame, this is not what I wanted in this case. I hope everything is plotted on the K lines, and this is always good if I don't use start and end parameters in plot function.
Plot slicing image with custom indicator in master frame cause unexpected result
I have developed a custom indicator which is plotted in master frame. In order to reduce the size of saved image, I added start and end parameters in plot function like this: plot(plotter=myPlotter, start=startbar, end=endbar). However, I found sometimes the image will be compressed in y axis since the value of my indicator may larger than the maximum value between startbar and endbar. I'm sure not if there is any easy solution to fix, if yes, please let me know, thanks.
I made a quick fix in plot.py, updated drawtag as following:
def drawtag(self, ax, x, y, facecolor, edgecolor, alpha=0.9, **kwargs): label = y ylim = ax.get_ylim() if y > ylim: y = ylim txt = ax.text(x, y, '%.2f' % label, va='center', ha='left', fontsize=self.pinf.sch.subtxtsize, bbox=dict(boxstyle=tag_box_style, facecolor=facecolor, edgecolor=edgecolor, alpha=alpha), # 3.0 is the minimum default for text zorder=self.pinf.zorder[ax] + 3.0, **kwargs)
This will fix my problem but I'm sure there should be better solutions. I'm new to backtrader and python. This is my plotted image before the fix.