散景季度轴

时间:2018-07-25 15:45:31

标签: python numpy bokeh

我正在尝试清理由以下代码创建的vbar的x轴,但遇到了问题。该图显示了可追溯到90年代初的按季度划分的帐户余额,按季度显示出很多混乱情况。我已经看到date_time在此问题中被引用:Datetime on an X Axis in Bokeh,但我不认为它直接适用于我要完成的工作。我只是想减少季度标签的数量,以使轴更整洁,更美观。目前,它们存储为字符串,我认为这是问题1。在Bokeh中有一种简单的方法吗?

def create_plot(top_level_data, source):
        #Builds initial plot with styles
        #Returns Graph obj

        #Create figure
        plot = figure(x_range = sorted(set(top_level_data['QTR'])), title="Account Balance", 
                    tools=["save, wheel_zoom,box_zoom,reset, pan"], 
                    background_fill_color = "white",
                plot_width=1000, plot_height=800)

        #main title formatting
        plot.title.align = "center"
        plot.title.text_color = "midnightblue"
        plot.title.text_font_size = '18pt'

        #axis title formatting
        plot.yaxis.axis_label = "Millions"
        plot.xaxis.axis_label = "Quarters"
        plot.xaxis.axis_label_text_color = "midnightblue"
        plot.yaxis.axis_label_text_color = "midnightblue"
        plot.xaxis.axis_label_text_font_size = "14pt"
        plot.yaxis.axis_label_text_font_size = "14pt"
        plot.y_range.start = 0
        plot.xaxis.major_label_orientation = "vertical"
        plot.xgrid.grid_line_color = None

        #formating of VBar
        plot.vbar(x = "x", top ="top", source=source, width = 1, fill_color="#036564", line_color="#033649")

        return plot

0 个答案:

没有答案