Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.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图形中删除填充或边距_Python_Bokeh_Figure - Fatal编程技术网

Python 从Bokeh图形中删除填充或边距

Python 从Bokeh图形中删除填充或边距,python,bokeh,figure,Python,Bokeh,Figure,有没有可能去掉bokeh人物侧面的填充物(或边距)? 我一直在看各种各样的数据,它们的左边似乎都有一个空白区域。我还试着改变边界 例如:s1.min\u border\u left=0或将其更改为s1.min\u border\u left=40 但它似乎不起作用,它改变了边界,但不知何故,似乎有一个填充是固定的,不可更改的,这是我想要摆脱的区域的一个例子: 那么,有没有可能摆脱这种情况,只需将图形粘贴到浏览器的左侧 打开生成的HTML页面,并将宽度90%替换为100%如果使用bokeh服务器,

有没有可能去掉bokeh人物侧面的填充物(或边距)? 我一直在看各种各样的数据,它们的左边似乎都有一个空白区域。我还试着改变边界 例如:
s1.min\u border\u left=0或将其更改为s1.min\u border\u left=40

但它似乎不起作用,它改变了边界,但不知何故,似乎有一个填充是固定的,不可更改的,这是我想要摆脱的区域的一个例子: 那么,有没有可能摆脱这种情况,只需将图形粘贴到浏览器的左侧


打开生成的HTML页面,并将宽度90%替换为100%

如果使用bokeh服务器,您可以使用类似的内容添加外部css表来修改页边距

html, body {
    display: block;
    margin: 0 auto;
    width: 99%;
} 

根据其他答案,下面是一个可能会派上用场的片段:

import os
import re
import tempfile
import webbrowser
import time

from bokeh.io import output_file, save


def save_bokeh_nomargins(plot, filename):
    """
    Saves a bokeh plot/layout without having the left margin.
    """
    # Strategy:
    #  1. save the plot to a temp file
    #  2. change the offending line of code
    #  3. save the result to the destination file
    ftemp = tempfile.mktemp()
    try:
        output_file(ftemp)
        save(plot)
        with open(ftemp) as ftemph, open(filename, "w") as fouth:
            fouth.write(re.sub("width: 90%;", "width: 100%;", ftemph.read(), count=1))
    finally:
            os.remove(ftemp)


def show_bokeh_nomargins(plot):
    """
    Displays a bokeh plot/layout without having the left margin.
    """
    ftemp = tempfile.mktemp()
    try:
        save_bokeh_nomargins(plot, ftemp)
        webbrowser.open(ftemp)
        time.sleep(1)
    finally:
        os.remove(ftemp)
我应该注意到,这有点粗糙,如果文件中的其他任何位置都有
width:90%
,则可能会出错