Code
# Import libraries
import numpy as np
import pandas as pd
from itables import init_notebook_mode
init_notebook_mode(all_interactive=True)
import holoviews as hv
hv.extension('bokeh')Unveiling Insights with Less Effort by Using HoloViews
Jesus LM
Apr, 2024
For data analytics, the magic lies in transforming raw numbers into visuals that reveal hidden patterns and trends. But the process of creating these visualizations can often be cumbersome, requiring extensive coding and customization. Here’s where HoloViews steps in, offering a refreshing approach to data visualization in Python.
HoloViews is an open-source Python library designed to streamline data analysis and visualization. It departs from the traditional method of meticulously crafting plots line by line. Instead, HoloViews focuses on a declarative approach, where you describe your data and desired visualization, and it takes care of the intricate details. This allows you to express your ideas with concise code, freeing you to delve deeper into your story-telling.
Several factors make HoloViews an attractive option for data visualization:
HoloViews boasts a user-friendly syntax, enabling you to create complex visualizations with minimal code. This focus on brevity empowers you to iterate quickly and explore your data efficiently.
HoloViews integrates seamlessly with popular data structures like NumPy and Pandas, effortlessly handling your data. Additionally, it plays well with different plotting backends like Bokeh, Plotly and Matplotlib, giving you control over the final look and feel of your visualizations.
HoloViews visualizations are not static images. They can be interactive, allowing users to zoom, pan, and explore the data from various angles. This interactivity fosters deeper engagement and a richer understanding of the information.
The HoloViews ecosystem extends beyond the core library. It encompasses projects like hvPlot for quick visualizations and GeoViews for crafting geographical visualizations. This suite of tools caters to a wide range of data exploration needs.
| prov | gdpr | year | gdp | pop | finv | trade | fexpen | uinc |
|---|---|---|---|---|---|---|---|---|
|
Loading ITables v2.2.3 from the init_notebook_mode cell...
(need help?) |
# Customization specs
grid_style = {'grid_line_color': 'white',
'grid_line_width': 2.,
}
# Create chart
curves_app = hd.to(hv.Bars, kdims=['year'], vdims=['gdp'], groupby='Province',)
# Chart options
curves_app.opts(height=500,
width=650,
xlabel='Year',
tools=['hover'],
ylabel='GDP',
xrotation=45,
toolbar=None, #above, below, left, right
fill_color='#1c2841',
line_color='black',
bgcolor='#f6f6f6',
show_grid=True,
gridstyle=grid_style,
)You can select a Province from the filter to get its correspondent chart.
As you gain experience with HoloViews, you can delve into its more advanced features.
HoloViews allows for extensive customization, enabling you to tailor your visualizations to perfectly suit your needs and branding.
Furthermore, HoloViews integrates well with other data science libraries within the Python ecosystem, fostering a powerful and cohesive environment for data exploration and analysis.
Jesus LM
Economist & Data Scientist