Python Script and R Script Visual



Before working with Python and R script visuals, both software should be installed in your system. You can utilize the Python and R script visual in the BI desktop environment after installing this software.

How to Check if Python is Installed on Your System?

Step 1 − You need to open the BI desktop and navigate to the File tab, click on the Options and Settings, and then choose "Options" where so many options are available.

Python is Installed on Your System

You can click on the Python scripting and verify the correct path of the Python environment. And then click on the "OK".

Python is Installed on Your System 1

Step 2 − You may select the "Get Data" and then click on the "More...".

Python is Installed on Your System 2

Another "Get Data" dialog box will appear where you may click on the "Other", select the "Python Script" and then click on "Connect".

Python is Installed on Your System 3

Step 3 − Now, you may enter the following code in the Python script to create two columns named "Student" and "Marks" which consist of five rows and click on "OK".

import pandas as d1
data = [['Rihaan',95],['Henry',85],['Karan',78],
   ['Joseph',89],['Diana',54]]
sd = d1.DataFrame(data,columns=['Student','Marks'])
print (sd)
Python is Installed on Your System 4

Step 4 − The "Navigator" dialog box will open where you can see the preview of the "sd" table. Moreover, you may click on the "sd" table under Python[1] and click on "Load".

Python is Installed on Your System 5

Step 5 − You can select the Python visual from the "Visualizations". The default "Python visual" is displayed on the canvas. But no field values are populated in the visual. To do this, you need to add the desired field values into the Values section.

Python is Installed on Your System 6

Step 6 − You can select the "Student", and "Marks" fields under the "Values" section. You need to write the Python code in the Python script editor as highlighted in the screenshot to plot the chart. After writing the code, click on "Run" to deploy the script code.

Python is Installed on Your System 7

You may click on the focus mode to view the chart which is constructed from the Python visual.

Python is Installed on Your System 8

R Script Visual

BI desktop is a powerful tool and compatible to work with extensive libraries of R script language to develop complex charts.

How to Check if R Script is Installed on Your System?

You can click on the BI desktop, navigate to the "File" tab, and click on the "Option and settings".

R Script is Installed on Your System

And then you may choose "Options" under "Options and settings".

R Script is Installed on Your System 1

Now, you can choose "R scripting" under "Global", verify the path of the R language, and then click OK.

R Script is Installed on Your System 2

How to Develop the R visual?

You can open sheet2 of the "C:\Users\Aarti\Documents\aq.pbix" dataset. After that, select the R visual from the Visualization.

Develop the R visual

Another dialog box "Enable script visuals" appears where you can click on "Enable".

Develop the R visual 1

You can place the "Active Users Account", "Name" and Designation into the "Values" section from the Data pane. After placing the fields into the Values section. You need to write the following code in the R script and then click on "Run".

Develop the R visual 2

As you can see in the screenshot, the interactive visual that depicts an Active users account with its name and designation is populated on the canvas through R visual.

Develop the R visual 3

Formatting R Visual

The following sections like "Properties, Titles, Effects, Header icons, Alt text" are available under "Format Visual".

Formatting R Visual

The properties sections comprise Size, Position, Padding, and Advanced options.

Formatting R Visual 1

You may expand the Size tile and set the Height to 623 and width to 1030.

Formatting R Visual 2

You may expand the "Title" that consists of the "Title", "Subtitle", "Divider" and spacing options.

Formatting R Visual 3

You may expand the "Title" and enter the "Analysis of the Active user's Account" under "Text", select Heading 5, click on the "Italics", change the Font style to "Cambria" and increase the font size to 15. You may also the alter title text color under the "Text color".

Formatting R Visual 4

As you can observe in the screenshot, the formatting of the Title has been altered.

Similarly, you can customize the subtitle of the visual also. To do this, just expand the "Subtitle", select "Heading 6" from the given list under "Heading", change the font style to "Trebuchet MS" and increase the font size to 12. Select Italics and choose the desired color "D9B300" from the drop-down list.

Formatting R Visual 5

You may also turn on the "Divider" button to partition the title with the rest of the visual part.

Formatting R Visual 6

You can further click on the "Effects" comprising Background, Visual border, and shadow options.

Formatting R Visual 7

You may expand the "Background" and select the "c7b8e7" color from the drop-down menu under the Color.

Formatting R Visual 8

Therefore, the background of the R script-generated visuals has been changed.

Formatting R Visual 9

You can also turn on the Visual border and Shadow toggle button to highlight the boundary and shadow of the designated visual.

Formatting R Visual 10

You may click on the "Header icons" and expand the Colors tile to change the desired Background color, Border color, and Icon color as shown below −

Formatting R Visual 11
Advertisements