Three-dimensional bar charts

In this recipe, we will create a three-dimensional bar chart. The three-dimensional bar chart will follow the same command as that of a scatter plot, but we will utilize the drop-line functionality to produce this 3D visualization.

Getting ready

Let's call the airquality dataset. In this particular recipe, we will use the Day, Month, and Temp variables. The Day and Month variables will represent two axes, whereas Temp will represent the third axis that gives the value of the temperature.

How to do it…

The command used here is similar to the scatter plot with the drop line added, but this time, we will hide the point and just represent each bar based on the value of the third variable. Here is the code:

scatterplot3d(Day,Month,Temp,type="h",lwd=5,pch=" ",color="grey10")
How to do it…

How it works…

The code that we used to produce the 3D bar chart is almost the same as the code that we used to produce a scatter plot. The noticeable feature of this code is that we have omitted the points using the pch=" " argument. Also, we increased the line width of the drop line so that it looks like a bar chart.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.239.251