Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/277.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Bokeh:如何保持y轴记号的稳定?_Python_Bokeh - Fatal编程技术网

Python Bokeh:如何保持y轴记号的稳定?

Python Bokeh:如何保持y轴记号的稳定?,python,bokeh,Python,Bokeh,在这里,我已经采取了一些措施,并通过多年的循环创建了一系列图表(我通过修改笔记本) 问题是,当中东国家在20世纪70年代达到顶峰时,y轴的记号(和图例)就会受到干扰。当我构建图时,我将尽可能多的东西保留在年循环之外,因此我的y轴代码如下所示: # Personal income (GDP per capita) y_low = int(math.floor(income_df.min().min())) y_high = int(math.ceil(income_df.max().max())

在这里,我已经采取了一些措施,并通过多年的循环创建了一系列图表(我通过修改笔记本)

问题是,当中东国家在20世纪70年代达到顶峰时,y轴的记号(和图例)就会受到干扰。当我构建图时,我将尽可能多的东西保留在年循环之外,因此我的y轴代码如下所示:

# Personal income (GDP per capita)
y_low = int(math.floor(income_df.min().min()))
y_high = int(math.ceil(income_df.max().max()))
y_data_range = DataRange1d(y_low-0.5*y_low, 1000000*y_high)

# ...

for year in columns_list:

        # ...

        # Build the plot
        plot = Plot(

            # Children per woman (total fertility)
            x_range=x_data_range,

            # Personal income (GDP per capita)
            y_range=y_data_range,
            y_scale=LogScale(),

            plot_width=800,
            plot_height=400,
            outline_line_color=None,
            toolbar_location=None, 
            min_border=20,
        )

        # Build the axes
        xaxis = LinearAxis(ticker=SingleIntervalTicker(interval=x_interval), 
                           axis_label="Children per woman (total fertility)", 
                           **AXIS_FORMATS)
        yaxis = LogAxis(ticker=LogTicker(), 
                        axis_label="Personal income (GDP per capita)",
                        **AXIS_FORMATS)
        plot.add_layout(xaxis, 'below')
        plot.add_layout(yaxis, 'left')

如您所见,我将数据范围增加了10^6倍,但没有任何效果。是否需要添加一些参数来保持y轴记号(和图例)稳定?

不要使用
DataRange1d
,这就是“自动测距”的实际功能。如果您知道要始终显示在前面的完整范围,请使用
范围1d

Plot(y_range=Range1d(low, high), ...) 
或更多为方便起见,这也将起作用:

Plot(y_range=(low, high), ...) 

这就解决了!谢谢