Book Image

R Graphs Cookbook Second Edition

Book Image

R Graphs Cookbook Second Edition

Overview of this book

Table of Contents (22 chapters)
R Graphs Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

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 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...