Power BI

# Creating a Heatmap in Power BI using Python

In our last Power BI training in Melbourne, we introduced python as a language which can be used to create stunning visuals in Power BI. Python’s integration with Power BI desktop has made it easy for data scientists to create python-based visualization plots in Power BI. We have created a blog series to enlist the visuals that can be created in Power BI using Python.

Here’s the link to the blog series: https://powerbitraining.com.au/category/python-scripting-in-power-bi/

So far, we have covered:

· Box Plot

A Boxplot gives a summary of your data. It depicts if your data is symmetrical and highlights the outliers. It also indicates how your data is distributed in the dataset.

For complete step by step guide: https://powerbitraining.com.au/creating-a-box-plot-using-python-in-power-bi/

· Plot Visualization

This visualization plot draws lines in the plotting area. We will be using the powerful Matplotlib library for this plot and all other plots in the blog series. The picture below shows the use of  plot() visualisation. If you use a single list then matplotlip will assume the sequence as y values and will automtaically generates x values for it. The x values start from 0.

For complete step by step guide: https://powerbitraining.com.au/creating-plot-visualization-using-python-in-power-bi/

·  Violin Plot

Violin plots are used to visualize the distribution of numeric variables for one or multiple groups, it allows you to understand the density of data more deeply. It is an upgraded version of the box plot. In the image below, the violin plot is showing a relationship between the petal width and petal length of the data points. It is showing that the data set does not have a continuity in the values. Most of the points are distributed around the petal length with value greater than 3. To use Violin plots you have to install Seaborn library, it is another data visualization library provided by python to generate high-level statistical graphs.

For complete step by step guide: https://powerbitraining.com.au/create-a-violin-plot-in-power-bi-using-python/

·  Create a Joint Plot

A joint plot is an upgraded form of scatter plot. It is used to observe the correlation between two variables. To create a joint plot, we will write the following code.

For complete step by step guide: https://powerbitraining.com.au/creating-a-joint-plot-in-power-bi-using-python/

Creating a Heat Map:

Heatmap is a correlation plot. It is a very powerful data analysis.  The data values in the heatmap are represented through colors.

1. Open the Python Script Editor.

2. Enter the code as shown below.

The code takes the whole dataset as an input and adds a color gradient ‘coolwarm’. There are numerous types of color gradients within the cmap parameter. It generates the following plot

The heat map is showing a relationship between the four dimensions through colors. The darker the shade shows a strong relationship between the dimensions. For example, petal length has the strongest relationship with itself (which is true); The second strongest relationship is with petal width; the third with sepal length and the least with petal width. This means a change in the value of petal length will have the strongest impact on petal width.

Conclusion:

A heat map is a visual that shows the correlation between two variables using color shades. The darker shades represent a higher correlation which means that changing one variable will have a direct impact on the other. Whereas the lighter shades represent lower correlation values. In this blog post, python’s Matplotlib and Seaborn libraries have been used to create a heat map in Power BI desktop.

More Checkouts for Power BI Training in Australia.