Matplotlib/Mplfinance-如何更改線條和條的顏色

一直在使用Mplfinance及其強大的功能。我一直在努力改變一些子地塊的顏色。

我使用外部軸方法成功地使用了文檔中的'mpf.make_addplot方法。我已經閱讀了關于樣式的文檔。但是,如何將樣式應用于其中一個子場景,而不僅僅是整個情節?

我已經添加了我的代碼和它生成的圖表的一個圖像,該函數通過道具傳遞圖表數據。

我已將圖像標記為“A”,其中有一條線我想更改其顏色,這是df['counts']添加圖,標記為“Tweets”。另外,對于標有“B”的部分,我想改變條的顏色,如果可能的話,根據它是正片還是負片,使它變成不同的顏色。

def makeCharts_CountsOHLC(self, props):

    fig = props['fig']
    df = props['df']
    symbol = props['symbol']
    start = props['min_date']
    end = props['max_date']

    # Configure the axes
    ax1 = fig.add_subplot(5,1,(1,2))
    ax2 = fig.add_subplot(5,1,3, sharex=ax1)
    ax3 = fig.add_subplot(5,1,4, sharex=ax1)
    ax4 = fig.add_subplot(5,1,5, sharex=ax1)

    # Create add plots
    aps = [
        mpf.make_addplot(
        df['count_s'], 
        ax=ax2, 
        ylabel='Tweets',
        ),
        
        mpf.make_addplot(
        df['sentiment'], 
        type='bar',
        ax=ax3,
        ylabel='Sentiment',            
        )]
    
    ax1.tick_params(labelbottom=False)
    ax2.tick_params(labelbottom=False)
    ax3.tick_params(labelbottom=False)

    # Functions to add a day to date and format dates 
    date_p1 = lambda x: dt.strftime(pd.to_datetime(x) + td(days=1), '%d %b %y')
    fmt_date = lambda x: dt.strftime(pd.to_datetime(x), '%d %b %y')

    title = f'{symbol} Price and Volume Traded from {fmt_date(start)} until {date_p1(end)}'

    # Plot the chart
    mpf.plot(
        df,
        type='candle',
        ax = ax1,
        volume = ax4,
        addplot = aps,
        xrotation = 0,
        datetime_format = '%b %d',
        axtitle = title,
        ylabel = 'Price ($USD)',
        tight_layout = True
        )

    # Format the prive of the y axis 
    mkfunc = lambda x, pos: '%1.1fM' % (x * 1e-6) if x >= 1e6 else '%1.1fK' % (x * 1e-3) if x >= 1e3 else '%1.1f' % x
    mkformatter = matplotlib.ticker.FuncFormatter(mkfunc)
    ax1.yaxis.set_major_formatter(mkformatter)

    # Adjustments to plot and save
    plt.subplots_adjust(hspace=0)
    plt.savefig(fname=props['save_path'], dpi=self.cconf.get('RESOLUTION'))
    plt.close('all')
    fig.clear()

? 最佳回答:

mpf.make_addplot()有一個kwargcolor=,你應該幫助它。

作為一般規則,代碼中列出了所有可用的KWARG:

  • 這里是mpf.plot(),和
  • 這里是mpf.make_addplot()
主站蜘蛛池模板: 精品一区二区三区色花堂| 久久精品无码一区二区无码| 中文字幕色AV一区二区三区| 亚洲AV无码一区二区三区电影 | 一区二区三区免费精品视频| 国产产一区二区三区久久毛片国语| 精品欧洲av无码一区二区| 亚洲国产一区在线观看| 精品国产乱子伦一区二区三区| 午夜无码一区二区三区在线观看| 日韩电影在线观看第一区| 久久久精品日本一区二区三区| 无码aⅴ精品一区二区三区| 国产成人欧美一区二区三区| 一区二区在线视频| 无码少妇A片一区二区三区| 精品人妻系列无码一区二区三区| 伊人色综合一区二区三区| 久久精品国产一区二区| 国产免费播放一区二区| 香蕉在线精品一区二区| 亚洲国产精品一区二区第一页 | 男人的天堂精品国产一区| 色窝窝免费一区二区三区 | 中文字幕一区精品| 亚洲片一区二区三区| 区三区激情福利综合中文字幕在线一区亚洲视频1 | 亚洲欧美国产国产一区二区三区 | 亚洲变态另类一区二区三区| 国产一区二区精品久久凹凸| 无码国产伦一区二区三区视频 | 日韩一区二区三区射精| 国产主播一区二区三区 | 日本免费电影一区二区| 午夜福利国产一区二区| 文中字幕一区二区三区视频播放| 亚洲AV无码一区二区三区电影| 精品欧洲av无码一区二区| 中文字幕国产一区| 亚洲一区中文字幕| 正在播放国产一区|