The Holoviz ecosystem is a suite of compatible tools designed to make data visualization in Python easier and more powerful. It supports every stage of data analysis, from importing and cleaning data, exploring, hypothesis testing, generating accurate and compelling diagrams, to sharing and deploying live applications.
The main features are as follows:
Representative components include the following:
Thus, Holoviz is built on top of the Python scientific and technological stack and is an ecosystem that comprehensively supports data visualization.
hvplot is a high-level API developed as part of the Holoviz ecosystem (Holoviews, Panel, Datashader, etc.) that allows you to visualize pandas/xarray/Dask data directly.
In particular, it is strong in meeting the need for "interactive visualization without increasing the amount of code."
hvplot operates as an extension of pandas.
import hvplot.pandas
This alone adds the .hvplot method to pandas DataFrames/Series. By default, Bokeh is used as the backend, but you can also specify matplotlib.
!pip install hvplot
import pandas as pd
import matplotlib.pyplot as plt
# Sample DataFrame
data = {'Year': [2017, 2018, 2019, 2020, 2021],
'Sales': [250, 300, 400, 350, 500]}
df = pd.DataFrame(data)
# Plotting a line graph
df.plot(x='Year', y='Sales', kind='line')
plt.xlabel('Year')
plt.ylabel('Sales')
plt.title('Yearly Sales')
plt.show()
import hvplot.pandas
#hvplot.extension('bokeh')
plot = df.hvplot(x='Year', y='Sales', kind='line')
plot.opts(xlabel='Year')
plot.opts(ylabel='Sales')
plot.opts(title='Yearly Sales')
hvplot.extension('matplotlib')
plot2 = df.hvplot(x='Year', y='Sales',kind='line')
plot2.opts(xlabel='Year')
plot2.opts(ylabel='Sales')
plot2.opts(title='Yearly Sales')
Because hvplot uses Holoviews internally, zoom, pan, hover, and toolbars are automatically included.
Without additional code, the following operations are possible:
When drawing a graph with hvplot, specify the graph type as a string or as a method in the hbplot kind option.
* Pie charts are not officially supported.
You can adjust axis labels, colors, fonts, etc. using .opts.
import pandas as pd
import hvplot.pandas
df=pd.DataFrame({'x':[1,2,3],'y':[4,5,2]})
df.hvplot.line(x='x',y='y')
df=pd.DataFrame({'section': ['Div-A', 'Div-B', 'Div-c', 'Div-D', 'Div-E'],'students': [23,17,35,29,12]})
df.hvplot.bar(x='section',y='students')
df=pd.DataFrame({'data':[12,80,30,65,60,73,55,54]})
plot=df.hvplot.hist(y='data', bins = 'auto')
plot.opts(title="HISTOGRAM")
plot.opts(xlabel='MARKS')
plot.opts(ylabel='STUDENTS')
plot
girls_grades = [83, 90, 71, 80, 100, 87, 92, 99, 40, 34]
boys_grades = [70, 39, 59, 43, 100, 45, 74, 95, 87, 30]
grades_range = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
df=pd.DataFrame({'girls_grades':girls_grades,'boys_grades':boys_grades,'grades_range':grades_range})
plot1=df.hvplot.scatter(x='grades_range', y='girls_grades', color='r')
plot2=df.hvplot.scatter(x='grades_range', y='boys_grades', color='b')
plot=plot1*plot2
plot.opts(xlabel='Grades Range')
plot.opts(ylabel='Grades Scored')
plot.opts(title='scatter plot')
plot