How to Make an Area Plot in Python using Bokeh

How to Make an Area Plot in Python using Bokeh

Bokeh is an Interactive Data visualization library of Python. It creates its plots by using HTML and JavaScript languages. Its basic targets are modern website browsers for presenting provided elegance, concise construction of novel graphics with high-performance interactivity.

In this tutorial, we will learn how to create an area plot on a graph using the bokeh library.

Plotting the Area Plots

Area Plots can be defined as the filled regions between two series that share a common area. The Bokeh figure class has two functions, namely:

  • varea()
  • harea()

1. varea() Function:

The varea() function is used for vertically directed areas. It has one “X” coordinate array and two “Y” coordinate arrays, “Y1” and “Y2”, which would be filled between.

Syntax:

Syntax for varea() function is:

Parameter:

The varea() function accepts the following parameters:

  • x: It is the “x-coordinates” for the points of the area plot.
  • y1: It is the “y-coordinates” for the points of one side of the area plot.
  • y2: It is the “y-coordinates” for the points of the other side of the area plot.

Code:

Output:

How to Make an Area Plot in Python using Bokeh

2. harea() Function:

The harea() function of the Bokeh library is used for horizontally directed areas on a Graph. It has one “Y” coordinate array and two “X” coordinate arrays, “X1” and “X2”, which would be filled between.

Syntax:

Syntax for harea() function is:

Parameter:

The harea() function accepts the following parameters:

  • x1: It is the “x-coordinates” for the points of one side of the area plot.
  • x2: It is the “x-coordinates” for the points of the other side of the area plot.
  • y: It is the “y-coordinates” for the points of the area plot.

Code:

Output:

How to Make an Area Plot in Python using Bokeh

Conclusion

In this tutorial, we discussed how we could create area plots in vertical and horizontal directions using the varea() and harea() function of the bokeh library in Python.


原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/263314.html

(0)
上一篇 2022年5月30日
下一篇 2022年5月30日

相关推荐

发表回复

登录后才能评论