等高线#

等高线图包含每个等高线水平线的线条,以及每对等高线水平线之间的填充多边形。

详情

Bokeh API:

figure.contour, bokeh.models.ContourRenderer

更多信息:

等高线图

关键词:

等高线

import numpy as np

from bokeh.palettes import OrRd
from bokeh.plotting import curdoc, figure, show

x, y = np.meshgrid(np.linspace(0, 4, 33), np.linspace(0, 3, 25))
z = np.sin(np.pi*x) + np.cos(np.pi*y)
levels = np.linspace(-2.0, 2.0, 9)

fig = figure(width=600, height=500, toolbar_location=None, x_range=(0, 4), y_range=(0, 3),
             title=r'$$\text{Contour plot of } z = \sin(\pi x) + \cos(\pi y)$$')

contour_renderer = fig.contour(
    x, y, z, levels, fill_color=OrRd,
    line_color=['white']*4 + ['black']*5, line_dash=['solid']*5 + ['dashed']*4, line_width=2,
)

colorbar = contour_renderer.construct_color_bar()
fig.add_layout(colorbar, 'right')

curdoc().theme = 'dark_minimal'

show(fig)