Joint plot draws attention of many attendees of our Power BI training in Australia because this plot helps the users to detect the relationship between different variables using python inside the Power BI desktop. Python’s integration in Power BI desktop has opened a new door to newer visualization techniques. In this blog post, a step-by-step guide to creating a joint plot in Power BI using python has been presented. Before we get started, lets understand the basic concepts first.
What is a Joint Plot?
A joint consists of three subplots where:
- one plot displays a bivariate graph which shows how the dependent variable(Y) varies with the independent variable(X).
- The second plot is placed horizontally at the top of the bivariate graph, and it shows the distribution of the independent variable(X).
- The third plot is placed on the right margin of the bivariate graph with the orientation set to vertical and it shows the distribution of the dependent variable(Y).
Python libraries used in this blog:
In this blog post, Python’s two visualization libraries Matplotlib and Seaborn have been used. Matplotlib derives its name from MATLAB and was initially developed to provide MATLAB-like interface to the users. Matplotlib is mainly used to produce 2D graphs and 3D graphs with the help of toolkit. Seaborn on the other hand is the go-to library for exploratory data analysis. Seaborn has a dataset-oriented API with a capacity to examine the relationship between the variables. It adds to the capacities of Matplotlib for generating multi-structure graphs, formatting and styling of graphs and supporting built in themes.
Data set used in this blog:
For this blog you need to download IRIS dataset which is publicly available. You can download the dataset from https://gist.github.com/netj/8836201.
Helpful blogs for beginners:
- To install python, add path variables and verify installation: Getting Started with Python Scripting in Power BI | Power BI Training Australia
- For importing and manipulating data using Python scripts: Data Manipulation using Python Scripts | Power BI Training Australia
- Creating a basic box plot using Python in Power BI: Creating a box plot using Python in Power BI | Power BI Training Australia
- Creating plot visualization using Python in Power BI: Creating Plot Visualization using Python in Power BI | Power BI Training Australia
- Create a Villon Plot in Power BI: Create a Violin Plot in Power BI using Python | Power BI Training Australia
Opening the Script Editor
In order to create visuals, follow the below mentioned steps:
- Select Visualization Tab under the Visualizations Pane.
2. Click on Python Visual. The following window will appear.
3. Click on Enable to enable Python Scripts. The following window will appear.
Python script editor automatically creates the dataset using the library Pandas. It creates the data frame with required column fields.
4. Now to start scripting, drag and drop fields into the Visualizations pane. Or you may also check the checkboxes for adding them into the script editor.
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.
1. Open the Python Script Editor
2. Enter the code as shown in the screen shot below.
3. The following plot will be generated.
Python’s Matplotlib and Seaborn are used to develop multi-structure graphs such as a joint plot. A joint plot is used to visualize the relationship between different variables. It finds the correlation between two variables and displays it in a format that looks like an upgraded version of the scatter plot. In this blog post, a step-by-step guide on creating a joint plot using python in Power BI has been presented.
Learning Power BI from Scratch? Get a complete, in-depth introduction to Microsoft Power BI tool by attending our Power BI Basic Training Course.
More Checkouts for Power BI Training in Australia