Having finished the ‘Power BI Lissajous Curve Explorer’, I was not 100% happy with the Power BI Scatter Chart visualization.
- The data point options are too large for most of the Lissajous Curves and do not look as refined as their equivalents in Excel. This is a minor quibble, but I now realise it was one of the reasons I did not pick up Power BI earlier. Its charts looked too PowerPointy to me. But that was perhaps a function of the dashboards I saw – you know those ones built so that the CXO thinks they are flying an F-14 – it’s all Gauge & Pie Charts up the wazoo.
- It would be good to have more control of the data point format. Below, I compare what you see in the Format options for the Scatter Chart, under Shapes – the Size is set to 0% and the Marker Shape set to ‘•’, against what is rendered in the Chart:-
The Marker Shape appears to be an ASCII character whilst the Chart appears to use a Circle Shape that is, at 0% size, twice as big as the ASCII character.
TL;DR: I look at a simple R Scatterplot, how to format it, and compare it to the Power BI Scatter Chart.
NOTE: You’ll need Power BI & R installed to view this report.
Where do we go from here?
So, what are the alternatives?
- I had a look at other Visualizations, in the Power BI MarketPlace, but didn’t see one that would replace the Scatter Chart.
- I could attempt to create my own. For now, this will have to go on the ‘To do’ list.
- I could use an R Script Visual.
Option 3 it is then.
Let’s get R eady to R umble!
There is a huge amount of information on R Scatterplots out there and a simple search gave many examples and options. It really took all of 10 mins to get the final R Script Visual working (as long as you’ve already installed R on your PC, of course – otherwise it might take 15 mins).
Add an R Script Visual to your report – the ‘R script editor’ appears at the bottom of your screen asking you to drag fields into the Values area. I simply added x_DAX, y_DAX, and n, from the n Table.
Power BI does some magic in the background to create a dataframe – a virtual table used by R. It also helpfully(?) removes duplicate rows.
# Create dataframe
# dataset <- data.frame(x_DAX, y_DAX, n)
# Remove duplicated rows
# dataset <- unique(dataset)
You then need to add the R script to plot the Scatter Chart.
That was it. That line above. It produces this:-
You can then set the format of the chart.
data <- dataset
plot(data$x_DAX,data$y_DAX, col = "cornflowerblue", pch = 20, axes=FALSE, xlab=NA, ylab=NA)
In this code we:-
- Rename the dataset to be just ‘data’ (data <- dataset)
- Add x_DAX & y_DAX, as before
- Add a colour to the data points (col = “cornflowerblue”)
- Define the type of data point to be ‘•’ (pch = 20)
- Remove the axes (axes = FALSE)
- Remove the x & y labels (xlab = NA, ylab = NA)
Which gives us:-
Back in Power BI proper, we can add a Title for the R Script Visual and copy across the labels/text we used on the Power BI Scatter Chart.
And comparing the two, side-by-side:-
Power BI Lissajous Curves Explorer with R: Final Thoughts & Follow-up Posts
- The combination of Power BI and R works very well.
- I think I was a bit hard on the Power BI charting engine. Beauty is in the eye of the beholder, so preferences will be different, but for ‘simple’ Lissajous Curves I prefer the R Scatterplot – the lines are cleaner and more refined. However, some of the more ‘complex’ Curves benefit from the circle shape used by Power BI.
- To be investigated, but I wonder if it is possible to create a Power BI Visualization that does use ASCII characters or gives more control over the shapes used?