Câu trả lời này là một bản cập nhật cho gần đây hơn 0.12 .4 phiên bản Bokeh. Để biết thêm thông tin, các lệnh này được lấy từ trang Styling Visual Attributes của Bokeh documentation.
Để tắt dấu tick lớn và nhỏ thiết lập màu sắc của họ để None
:
p = bokeh.plotting.figure(plot_width=400, plot_height=400)
p.circle([1,2,3,4,5], [2,5,8,2,7], size=10)
p.xaxis.major_tick_line_color = None # turn off x-axis major ticks
p.xaxis.minor_tick_line_color = None # turn off x-axis minor ticks
p.yaxis.major_tick_line_color = None # turn off y-axis major ticks
p.yaxis.minor_tick_line_color = None # turn off y-axis minor ticks
Để tắt các nhãn đánh dấu thiết lập kích thước phông chữ để '0pt'
:
p.xaxis.major_label_text_font_size = '0pt' # turn off x-axis tick labels
p.yaxis.major_label_text_font_size = '0pt' # turn off y-axis tick labels
Một kết quả tương tự có thể có thể đạt được bằng cách đặt màu phông chữ thành 'Không', với bất lợi là khoảng trống vẫn được duy trì cho các nhãn đánh dấu.
p.xaxis.major_label_text_color = None # turn off x-axis tick labels leaving space
p.yaxis.major_label_text_color = None # turn off y-axis tick labels leaving space
Đoạn mã này minh họa việc xóa cả hai dòng đánh dấu chính và nhỏ cũng như nhãn đánh dấu.
import bokeh.io
import bokeh.plotting
import bokeh.layouts
bokeh.io.output_file('remove_tick_marks.html')
p0 = bokeh.plotting.figure(plot_width=200, plot_height=200,
x_axis_label='x', y_axis_label='y',
title='original')
p0.circle([1,2,3,4,5], [2,5,8,2,7], size=10)
p1 = bokeh.plotting.figure(plot_width=200, plot_height=200,
x_axis_label='x', y_axis_label='y',
title='remove tick marks')
p1.circle([1,2,3,4,5], [2,5,8,2,7], size=10)
p1.xaxis.major_tick_line_color = None # turn off x-axis major ticks
p1.xaxis.minor_tick_line_color = None # turn off x-axis minor ticks
p1.yaxis.major_tick_line_color = None # turn off y-axis major ticks
p1.yaxis.minor_tick_line_color = None # turn off y-axis minor ticks
p2 = bokeh.plotting.figure(plot_width=200, plot_height=200,
x_axis_label='x', y_axis_label='y',
title='remove tick labels')
p2.circle([1,2,3,4,5], [2,5,8,2,7], size=10)
p2.xaxis.major_tick_line_color = None # turn off x-axis major ticks
p2.xaxis.minor_tick_line_color = None # turn off x-axis minor ticks
p2.yaxis.major_tick_line_color = None # turn off y-axis major ticks
p2.yaxis.minor_tick_line_color = None # turn off y-axis minor ticks
p2.xaxis.major_label_text_font_size = '0pt' # preferred method for removing tick labels
p2.yaxis.major_label_text_font_size = '0pt' # preferred method for removing tick labels
p3 = bokeh.plotting.figure(plot_width=200, plot_height=200,
x_axis_label='x', y_axis_label='y',
title='notice extra space')
p3.circle([1,2,3,4,5], [2,5,8,2,7], size=10)
p3.xaxis.major_tick_line_color = None # turn off x-axis major ticks
p3.xaxis.minor_tick_line_color = None # turn off x-axis minor ticks
p3.yaxis.major_tick_line_color = None # turn off y-axis major ticks
p3.yaxis.minor_tick_line_color = None # turn off y-axis minor ticks
p3.xaxis.major_label_text_color = None #note that this leaves space between the axis and the axis label
p3.yaxis.major_label_text_color = None #note that this leaves space between the axis and the axis label
grid = bokeh.layouts.gridplot([[p0, p1, p2, p3]])
bokeh.io.show(grid)
Không, đây có lẽ là cách tốt nhất hiện nay để làm điều đó. Có lẽ chúng ta có thể thêm từ khóa arg khác vào 'con số' nhưng hành động cân bằng của nó, thêm thuận tiện nhưng tránh" tham số canh ". Nếu bạn có đề xuất cải thiện chính tả, v.v. Tôi khuyến khích bạn gửi chúng trên bộ theo dõi vấn đề GH Bo, đầu vào đó luôn được chào đón. – bigreddot
Mặc dù bạn cũng có thể đặt 'major_label_text_font_color = None' và có tác dụng đó để xóa các nhãn chính. Tôi nghĩ rằng đó là sở thích của tôi hơn thiết lập kích thước font chữ nhưng tôi sẽ thừa nhận không có nhiều sự khác biệt. – bigreddot
Cảm ơn @bigreddot, thật yên tâm khi thấy tôi không bỏ lỡ điều hiển nhiên. Tôi đến từ việc sử dụng ggplot2 nặng và dự kiến sẽ tìm thấy một công tắc đơn giản như trong http://www.cookbook-r.com/Graphs/Axes_(ggplot2)/ nhưng tôi hài lòng với giải pháp tạm thời này và tôi sẽ xem xét việc gửi một vấn đề nếu tôi có một gợi ý hữu ích để thực hiện. – gauden