☰Read-only archive⌕
Looking for help with Bokeh?

This is a read-only archive. Ask questions and join the conversation on GitHub.

Visit Community Support on GitHub →
Archived discussions · Captured October 28, 2026

Create `figure` without default axes

Community Support
Egor_Panfilov
Egor_Panfilov

In continuation of Generalize the configuration of axes · Issue #4042 · bokeh/bokeh · GitHub .

I’ve tried to follow Bryan’s second suggestion - to create the figure without default axes:

import pandas as pd

from bokeh.io import gridplot, output_file, show

from bokeh.plotting import figure

from bokeh.models import LinearAxis, Range1d

output_file(“test.html”)

df = pd.DataFrame()

df[‘time’] = [1, 2, 3, 4, 5]

df[‘temperature’] = [30, 31, 32.5, 33, 31]

df[‘humidity’] = [10, 30, 50, 20, 40]

df[‘sensor’] = [0.22, 0.12, 0.14, 0.08, 0.04]

---------- Doesn’t work -----------

s1 = figure(title=None, x_axis_location=None, y_axis_location=None)

s1 = figure(title=None, y_axis_location=None)

s1 = figure(title=None, x_axis_location=None)

-------------- Works --------------

s1 = figure(title=None)

-----------------------------------

s1.extra_x_ranges[‘time’] = Range1d(-1, 6)

s1.extra_y_ranges[‘temperature’] = Range1d(25, 35)

s1.extra_y_ranges[‘humidity’] = Range1d(0, 50)

s1.extra_y_ranges[‘sensor’] = Range1d(0, 0.25)

s1.extra_x_ranges = {

‘time’: Range1d(start=-1, end=6),

}

s1.extra_y_ranges = {

‘temperature’: Range1d(start=25, end=35),

‘humidity’: Range1d(start=0, end=50),

‘sensor’: Range1d(start=0, end=0.25),

}

s1.line(x=df[‘time’], y=df[‘temperature’],

    x_range_name='time', y_range_name='temperature',

color='orange', legend='temperature')

s1.line(x=df[‘time’], y=df[‘humidity’],

    x_range_name='time', y_range_name="humidity",

color="blue", alpha=0.5, legend='humidity')

s1.line(x=df[‘time’], y=df[‘sensor’],

    x_range_name='time', y_range_name="sensor",

color="red", legend='sensory data')

s1.add_layout(LinearAxis(x_range_name=‘time’, axis_label=‘Time’), ‘below’)

s1.add_layout(LinearAxis(y_range_name=‘temperature’, axis_label=‘Temperature’), ‘left’)

s1.add_layout(LinearAxis(y_range_name=‘humidity’, axis_label=‘Humidity’), ‘left’)

s1.add_layout(LinearAxis(y_range_name=‘sensor’, axis_label=‘Sensor’), ‘right’)

show(s1)

``

This code generates the .html file, but instead of full plot I get only toolbar (zoom, reset, etc). With -- Works -- uncommented everything is generated fine, but the redundant base axes are also presented.

I’ve discovered some initialization code in https://github.com/bokeh/bokeh/blob/master/bokeh/plotting/figure.py#L49-L79 which is called for base axes only, but cannot find out where could be the difference, which prevents the figure from being presented.

Does anyone have any ideas?

⌁   Link to post
Bryan
Bryan

OK, there is an actual bug here. If I comment out the add_layout calls that the bottom, the generated Bokeh JSON still has two (partially configured) LinearAxis objects. It should not have any. So the good news is I think this (hopefully) a simple fix on the python side. Can you re-open the issue (as a bug) and link this ML thread?

Thanks for your patience,

Bryan

···

On Mar 19, 2016, at 4:00 PM, Egor Panfilov <multicolor.mood@gmail.com> wrote:

In continuation of Generalize the configuration of axes · Issue #4042 · bokeh/bokeh · GitHub .

I've tried to follow Bryan's second suggestion - to create the `figure` without default axes:

import pandas as pd

from bokeh.io import gridplot, output_file, show
from bokeh.plotting import figure
from bokeh.models import LinearAxis, Range1d

output_file("test.html")

df = pd.DataFrame()
df['time'] = [1, 2, 3, 4, 5]
df['temperature'] = [30, 31, 32.5, 33, 31]
df['humidity'] = [10, 30, 50, 20, 40]
df['sensor'] = [0.22, 0.12, 0.14, 0.08, 0.04]

# ---------- Doesn't work -----------
s1 = figure(title=None, x_axis_location=None, y_axis_location=None)
# s1 = figure(title=None, y_axis_location=None)
# s1 = figure(title=None, x_axis_location=None)
# -------------- Works --------------
# s1 = figure(title=None)
# -----------------------------------

s1.extra_x_ranges['time'] = Range1d(-1, 6)
s1.extra_y_ranges['temperature'] = Range1d(25, 35)
s1.extra_y_ranges['humidity'] = Range1d(0, 50)
s1.extra_y_ranges['sensor'] = Range1d(0, 0.25)

# s1.extra_x_ranges = {
# 'time': Range1d(start=-1, end=6),
# }
# s1.extra_y_ranges = {
# 'temperature': Range1d(start=25, end=35),
# 'humidity': Range1d(start=0, end=50),
# 'sensor': Range1d(start=0, end=0.25),
# }

s1.line(x=df['time'], y=df['temperature'],
        x_range_name='time', y_range_name='temperature',
  color='orange', legend='temperature')
s1.line(x=df['time'], y=df['humidity'],
        x_range_name='time', y_range_name="humidity",
  color="blue", alpha=0.5, legend='humidity')
s1.line(x=df['time'], y=df['sensor'],
        x_range_name='time', y_range_name="sensor",
  color="red", legend='sensory data')

s1.add_layout(LinearAxis(x_range_name='time', axis_label='Time'), 'below')
s1.add_layout(LinearAxis(y_range_name='temperature', axis_label='Temperature'), 'left')
s1.add_layout(LinearAxis(y_range_name='humidity', axis_label='Humidity'), 'left')
s1.add_layout(LinearAxis(y_range_name='sensor', axis_label='Sensor'), 'right')

show(s1)

This code generates the .html file, but instead of full plot I get only toolbar (zoom, reset, etc). With `-- Works --` uncommented everything is generated fine, but the redundant base axes are also presented.

I've discovered some initialization code in https://github.com/bokeh/bokeh/blob/master/bokeh/plotting/figure.py#L49-L79 which is called for base axes only, but cannot find out where could be the difference, which prevents the figure from being presented.

Does anyone have any ideas?

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+unsubscribe@continuum.io.
To post to this group, send email to bokeh@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/ddb7824b-852c-4bb8-9e9c-39db573dd602%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

⌁   Link to post
Bryan
Bryan

Yes, a very small fix and your code works:

diff --git a/bokeh/plotting/figure.py b/bokeh/plotting/figure.py
index 457cf08..3c3d06f 100644
--- a/bokeh/plotting/figure.py
+++ b/bokeh/plotting/figure.py
@@ -50,7 +50,10 @@ class Figure(Plot):
         if x_axiscls:
             if x_axiscls is LogAxis:
                 self.x_mapper_type = 'log'
- xaxis = x_axiscls(plot=self)
+ if x_axis_location is None:
+ xaxis = x_axiscls(plot=None)
+ else:
+ xaxis = x_axiscls(plot=self)
             if hasattr(xaxis.ticker, 'num_minor_ticks'):
                 xaxis.ticker.num_minor_ticks = _get_num_minor_ticks(x_axiscls, x_minor_ticks)
             axis_label = x_axis_label
@@ -66,7 +69,10 @@ class Figure(Plot):
         if y_axiscls:
             if y_axiscls is LogAxis:
                 self.y_mapper_type = 'log'
- yaxis = y_axiscls(plot=self)
+ if y_axis_location is None:
+ yaxis = y_axiscls(plot=None)
+ else:
+ yaxis = y_axiscls(plot=self)
             if hasattr(yaxis.ticker, 'num_minor_ticks'):
                 yaxis.ticker.num_minor_ticks = _get_num_minor_ticks(y_axiscls, y_minor_ticks)
             axis_label = y_axis_label

I'll submit a PR shortly.

Thanks,

Bryan

···

On Mar 19, 2016, at 4:00 PM, Egor Panfilov <multicolor.mood@gmail.com> wrote:

In continuation of Generalize the configuration of axes · Issue #4042 · bokeh/bokeh · GitHub .

I've tried to follow Bryan's second suggestion - to create the `figure` without default axes:

import pandas as pd

from bokeh.io import gridplot, output_file, show
from bokeh.plotting import figure
from bokeh.models import LinearAxis, Range1d

output_file("test.html")

df = pd.DataFrame()
df['time'] = [1, 2, 3, 4, 5]
df['temperature'] = [30, 31, 32.5, 33, 31]
df['humidity'] = [10, 30, 50, 20, 40]
df['sensor'] = [0.22, 0.12, 0.14, 0.08, 0.04]

# ---------- Doesn't work -----------
s1 = figure(title=None, x_axis_location=None, y_axis_location=None)
# s1 = figure(title=None, y_axis_location=None)
# s1 = figure(title=None, x_axis_location=None)
# -------------- Works --------------
# s1 = figure(title=None)
# -----------------------------------

s1.extra_x_ranges['time'] = Range1d(-1, 6)
s1.extra_y_ranges['temperature'] = Range1d(25, 35)
s1.extra_y_ranges['humidity'] = Range1d(0, 50)
s1.extra_y_ranges['sensor'] = Range1d(0, 0.25)

# s1.extra_x_ranges = {
# 'time': Range1d(start=-1, end=6),
# }
# s1.extra_y_ranges = {
# 'temperature': Range1d(start=25, end=35),
# 'humidity': Range1d(start=0, end=50),
# 'sensor': Range1d(start=0, end=0.25),
# }

s1.line(x=df['time'], y=df['temperature'],
        x_range_name='time', y_range_name='temperature',
  color='orange', legend='temperature')
s1.line(x=df['time'], y=df['humidity'],
        x_range_name='time', y_range_name="humidity",
  color="blue", alpha=0.5, legend='humidity')
s1.line(x=df['time'], y=df['sensor'],
        x_range_name='time', y_range_name="sensor",
  color="red", legend='sensory data')

s1.add_layout(LinearAxis(x_range_name='time', axis_label='Time'), 'below')
s1.add_layout(LinearAxis(y_range_name='temperature', axis_label='Temperature'), 'left')
s1.add_layout(LinearAxis(y_range_name='humidity', axis_label='Humidity'), 'left')
s1.add_layout(LinearAxis(y_range_name='sensor', axis_label='Sensor'), 'right')

show(s1)

This code generates the .html file, but instead of full plot I get only toolbar (zoom, reset, etc). With `-- Works --` uncommented everything is generated fine, but the redundant base axes are also presented.

I've discovered some initialization code in https://github.com/bokeh/bokeh/blob/master/bokeh/plotting/figure.py#L49-L79 which is called for base axes only, but cannot find out where could be the difference, which prevents the figure from being presented.

Does anyone have any ideas?

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+unsubscribe@continuum.io.
To post to this group, send email to bokeh@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/ddb7824b-852c-4bb8-9e9c-39db573dd602%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

⌁   Link to post
Bryan
Bryan
···

On Mar 19, 2016, at 4:21 PM, Bryan Van de Ven <bryan@bokeh.org> wrote:

Yes, a very small fix and your code works:

diff --git a/bokeh/plotting/figure.py b/bokeh/plotting/figure.py
index 457cf08..3c3d06f 100644
--- a/bokeh/plotting/figure.py
+++ b/bokeh/plotting/figure.py
@@ -50,7 +50,10 @@ class Figure(Plot):
        if x_axiscls:
            if x_axiscls is LogAxis:
                self.x_mapper_type = 'log'
- xaxis = x_axiscls(plot=self)
+ if x_axis_location is None:
+ xaxis = x_axiscls(plot=None)
+ else:
+ xaxis = x_axiscls(plot=self)
            if hasattr(xaxis.ticker, 'num_minor_ticks'):
                xaxis.ticker.num_minor_ticks = _get_num_minor_ticks(x_axiscls, x_minor_ticks)
            axis_label = x_axis_label
@@ -66,7 +69,10 @@ class Figure(Plot):
        if y_axiscls:
            if y_axiscls is LogAxis:
                self.y_mapper_type = 'log'
- yaxis = y_axiscls(plot=self)
+ if y_axis_location is None:
+ yaxis = y_axiscls(plot=None)
+ else:
+ yaxis = y_axiscls(plot=self)
            if hasattr(yaxis.ticker, 'num_minor_ticks'):
                yaxis.ticker.num_minor_ticks = _get_num_minor_ticks(y_axiscls, y_minor_ticks)
            axis_label = y_axis_label

I'll submit a PR shortly.

Thanks,

Bryan

On Mar 19, 2016, at 4:00 PM, Egor Panfilov <multicolor.mood@gmail.com> wrote:

In continuation of Generalize the configuration of axes · Issue #4042 · bokeh/bokeh · GitHub .

I've tried to follow Bryan's second suggestion - to create the `figure` without default axes:

import pandas as pd

from bokeh.io import gridplot, output_file, show
from bokeh.plotting import figure
from bokeh.models import LinearAxis, Range1d

output_file("test.html")

df = pd.DataFrame()
df['time'] = [1, 2, 3, 4, 5]
df['temperature'] = [30, 31, 32.5, 33, 31]
df['humidity'] = [10, 30, 50, 20, 40]
df['sensor'] = [0.22, 0.12, 0.14, 0.08, 0.04]

# ---------- Doesn't work -----------
s1 = figure(title=None, x_axis_location=None, y_axis_location=None)
# s1 = figure(title=None, y_axis_location=None)
# s1 = figure(title=None, x_axis_location=None)
# -------------- Works --------------
# s1 = figure(title=None)
# -----------------------------------

s1.extra_x_ranges['time'] = Range1d(-1, 6)
s1.extra_y_ranges['temperature'] = Range1d(25, 35)
s1.extra_y_ranges['humidity'] = Range1d(0, 50)
s1.extra_y_ranges['sensor'] = Range1d(0, 0.25)

# s1.extra_x_ranges = {
# 'time': Range1d(start=-1, end=6),
# }
# s1.extra_y_ranges = {
# 'temperature': Range1d(start=25, end=35),
# 'humidity': Range1d(start=0, end=50),
# 'sensor': Range1d(start=0, end=0.25),
# }

s1.line(x=df['time'], y=df['temperature'],
       x_range_name='time', y_range_name='temperature',
  color='orange', legend='temperature')
s1.line(x=df['time'], y=df['humidity'],
       x_range_name='time', y_range_name="humidity",
  color="blue", alpha=0.5, legend='humidity')
s1.line(x=df['time'], y=df['sensor'],
       x_range_name='time', y_range_name="sensor",
  color="red", legend='sensory data')

s1.add_layout(LinearAxis(x_range_name='time', axis_label='Time'), 'below')
s1.add_layout(LinearAxis(y_range_name='temperature', axis_label='Temperature'), 'left')
s1.add_layout(LinearAxis(y_range_name='humidity', axis_label='Humidity'), 'left')
s1.add_layout(LinearAxis(y_range_name='sensor', axis_label='Sensor'), 'right')

show(s1)

This code generates the .html file, but instead of full plot I get only toolbar (zoom, reset, etc). With `-- Works --` uncommented everything is generated fine, but the redundant base axes are also presented.

I've discovered some initialization code in https://github.com/bokeh/bokeh/blob/master/bokeh/plotting/figure.py#L49-L79 which is called for base axes only, but cannot find out where could be the difference, which prevents the figure from being presented.

Does anyone have any ideas?

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+unsubscribe@continuum.io.
To post to this group, send email to bokeh@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/ddb7824b-852c-4bb8-9e9c-39db573dd602%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

⌁   Link to post

End of archived discussion · Replies are disabled