Приращение метки диаграммы боке

Я пытаюсь устранить посторонние метки на оси X на диаграмме, используя небольшой код, который я нашел в учебных пособиях по Bokeh. Ясно, что мне чего-то не хватает, так как я получаю следующую ошибку:

AttributeError: объект 'Chart' не имеет атрибута 'xaxis'

Я предполагаю, что проблема в том, что высокоуровневые диаграммы не работают как обычные графики. Это можно обойти?

import numpy


'''
***************** Craps Array Functions*****************
'''

def rollDie(n):
    import random    
    die = random.randint(1,n)
    return die

def crapsRoll(): 
    a = rollDie(6)
    b = rollDie(6)
    c = a + b
    return(c)

def crapsArray(count) :   
    import numpy as np
    rollcount = 0
    inc = 0
    rolls = []
    row = []
    while inc < count:
        inc = inc + 1
        rollcount = rollcount + 1
        roll = crapsRoll()
        row = [rollcount, roll]
        rolls.append(row)     
    else:
        rollsArray = np.asarray(rolls)
        print(' Rolls Done')    

    return(rollsArray)

temp = crapsArray(100)       
numpy.savetxt('test.csv', temp, fmt= '%3.0d', delimiter = ',', header = "roll,score", comments ='')

'''
********************* Bokeh Plots ***********************
'''
import pandas as pd
from bokeh.charts import Bar, output_file, show
from bokeh.plotting import figure 
from bokeh.models import FixedTicker

csv=pd.read_csv('test.csv')

output_file("craps.html")

p = figure(plot_width = 1000, plot_height = 400)

p = Bar(csv, 'roll', values = 'score', title = "Craps Outcomes", bar_width = 1, color = 'roll')
p.xaxis[0].ticker=FixedTicker(ticks=[0,25,50,75,100])

show(p)

person Josh Sigler    schedule 25.10.2015    source источник


Ответы (1)


xaxis и др. Удобные методы есть на bokeh.plotting.Figure. Однако диаграммы являются подклассом базового bokeh.models.Plot базового класса, поэтому их не существует. Вы можете использовать метод select для запроса объектов:

In [18]: from bokeh.models import LinearAxis

In [19]: p.select(LinearAxis)
Out[19]: [<bokeh.models.axes.LinearAxis at 0x108f4def0>]

Вероятно, было бы разумно упростить получение осей на диаграммах, пожалуйста, не стесняйтесь открывать проблему с запросом функции на GitHub, чтобы другие разработчики ядра могли ее увидеть и обсудить.

person bigreddot    schedule 26.10.2015
comment
Могу я попросить некоторую помощь по этому stackoverflow.com/questions/38709991/ - person Sitz Blogz; 02.08.2016