Problems with correlation graphs in bokeh

When I draw my data through rect()(from Bokeh), I get a separate line of horizontal blocks in my visualization. The data prints correctly and, as far as I know, is formatted correctly (it was type()verified that they were all lists). Can anyone diagnose this? If there is no problem here, I can add more code.

(If necessary: ​​Running Python 2.7.6 on Ubuntu 14.04)

    from bokeh.plotting import *
    from bokeh.objects import HoverTool, ColumnDataSource
    output_notebook()

    #All the same color just for testing
    colors = [
   "#191919", "#191919", "#191919", "#191919", "#191919", 
    "#191919", "#191919", "#191919", "#191919", "#191919",
    "#191919", "#191919", "#191919", "#191919", "#191919",
    "#191919", "#191919", "#191919", "#191919", "#191919", 
    "#191919", "#191919", "#191919", "#191919", "#191919"
    ]

    x_2 = []
    for i in trans_dat: x_2.append(i)

    y_2 = []
    for i in trans_dat.index: y_2.append(i)

    colors_2 = []
    kwordxstate_2 = []
    for y in y_2:
        for x in x_2:
            kword_state = trans_dat[x][y]
            kwordxstate_2.append(kword_state)
            colors_2.append(colors[kword_state])

    source = ColumnDataSource(
        data = dict(
            x_2=x_2,
            y_2=y_2,
            colors_2=colors_2,
            kwordxstate_2=kwordxstate_2,  
        )
    )

    rect(x_2, y_2, 1,1, source=source,
         x_range=x_2, y_range=y_2,
         color=colors_2, line_color=None,
         tools="resize,hover,previewsave", title="Keywords by state",
         plot_width=900, plot_height=400)

    grid().grid_line_color = None
    axis().axis_line_color = None
    axis().major_tick_line_color = None
    axis().major_label_text_font_size = "10pt"
    axis().major_label_standoff = 0
    xaxis().location = "top"
    xaxis().major_label_orientation = np.pi/3

    show()
+4
source share
1 answer

Ok, I need to have a complete prototype example trans_datto dig further. Here are some general comments that might help:

x_range y_range , .

x y , . x y .

, x_2 y_2 , . .

, :

  • : ["US", "Canada"]

  • y: ["Tech", "Agriculture"]

, x_range y_range. , - x y:

  • x: ["US", "US", "Canada", "Canada"]

  • y: ["Tech", Agriculture", "Tech", Agriculture"]

, . - :

  • x: ["US", "US", "Canada"]

  • y: ["Tech", Agriculture", Agriculture"]

( "", "" ).

: [0,10] [1,2] x y. , (0, 1.5) (5.5, 2).

( ) ( , )? , .

+5

Source: https://habr.com/ru/post/1544293/


All Articles