You need to change the visibility of the lines, not the axis.
I've done this in a project on Github that displays temperature and humidity data (amongst other things). The humidity data is the extra y axis and I have check boxes to show/hide temperature and/or humidity. Here's the function that shows/hides the lines on the chart:
def h_t_lines_changed(self, active):
"""Helper function for h_t_tab - turns lines on and off"""
for index in range(len(self.h_t_line)):
self.h_t_line[index].visible = index in active
Here's the line definitions:
self.h_t_line[0] = self.h_t_fig.line(x='Timestamp',
y='Temperature (C)',
source=self.source,
color="blue",
legend="Temperature",
line_width=2)
self.h_t_line[1] = self.h_t_fig.line(x="Timestamp",
y="Relative humidity (%)",
source=self.source,
y_range_name="humidity",
color="green",
legend="Humidity",
line_width=2)
and here's the checkbox code, including the callback:
resp_b = [0, 1]
h_t_check_head = Div(text="Responses")
h_t_check = CheckboxGroup(labels=["Temperature", "Humidity"],
active=resp_b,
name="Lines")
h_t_check.on_click(self.h_t_lines_changed)
I'm updating my project now. If you want me to post a link to it, let me know.