0

I am trying to clean up the x-axis of a vbar created by the below code, but am running into issues. The graph shows account balances by quarter dating back to the early 90s, which shows a lot of clutter by quarter. I've seen date_time referenced in this question: Datetime on an X Axis in Bokeh but I don't believe that it is directly applicable to what i'm trying to accomplish. I simply want to decrease the number of quarterly labels so that the axis is cleaner and more presentable. Currently, they are stored as strings, which I believe to be problem #1. Is there an easy way to do this in 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
StormsEdge
  • 854
  • 2
  • 10
  • 35
  • Possible duplicate of [How to show only evey nth categorical tickers in Bokeh](https://stackoverflow.com/questions/49172201/how-to-show-only-evey-nth-categorical-tickers-in-bokeh) – bigreddot Jul 25 '18 at 16:05
  • This is the same question/answer as https://stackoverflow.com/questions/49172201/how-to-show-only-evey-nth-categorical-tickers-in-bokeh In short: All categorical factors are shown on an axis, because categorical axes are not like continuous axes which can be easily and automatically summarized according to unamiguous rules. If you want something other than "all the factors", its incumbent on you to specify what is appropriate for your specific use case. – bigreddot Jul 25 '18 at 16:07

0 Answers0