官术网_书友最值得收藏!

Base graphics using the default package

It is well known that R has very powerful data visualization capabilities. The primary reason behind the powerful graphical utility of R is the low-level graphical environment. The grid graphic system of R makes data visualization much more flexible and intuitive. With the help of the grid package, we can draw very basic shapes that can be arranged to produce interesting data visualizations. There are functions in the grid graphics system that draw very basic shapes of a high-level data visualization, including lines, rectangles, circles, and texts along with some other functions that specify where to put which part of the visualization. Through the use of the basic function, we can easily produce components of high-level graphs, such as a rectangle, rounded rectangle, circle, line, and arrow. We will now see how we can produce these basic shapes. In a single visualization, we will show you all the output from the following code snippet:

# Calling grid library
library(grid)

# Creating a rectangle
grid.rect(height=0.25,width=0.25)

# A rounded rectangle
grid.roundrect(height=0.2,width=0.2) 

# A circle
grid.circle(r=0.1)

# Inserting text within the shape
grid.text("R Graphics")
# Drawing a polygon
grid.polygon()

Basic shapes using the grid package

For any high-level visualization, we can use the basic shapes and arrange them as required. Now, we will list some of the functions for high-level data visualization where the basic shapes have been used:

  • plot: This is a generic function that is used to plot any kind of objects. Most commonly, we use this function for x-y plotting
  • barplot: This function is used to produce a horizontal or vertical bar plot
  • boxplot: This is used to produce a box-whisker plot
  • pie: This is used to produce a pie chart
  • hist: This is used to produce a histogram
  • dotchart: This is used to produce cleveland dot plots
  • image, heatmap, contour, and persp: These functions are used to generate image-like plots
  • qqnorm, qqline, and qqplot: These functions are used to produce plots in order to compare distributions

We will provide specific recipes for each of these functions in the subsequent chapters.

主站蜘蛛池模板: 瑞金市| 礼泉县| 新沂市| 英超| 图木舒克市| 轮台县| 江达县| 黄龙县| 平顺县| 巨野县| 平阴县| 江西省| 平阳县| 和平区| 定远县| 安庆市| 伊宁市| 红原县| 苍溪县| 福鼎市| 凤阳县| 响水县| 潍坊市| 营口市| 台北市| 祁东县| 馆陶县| 汕头市| 汪清县| 安阳市| 敦煌市| 淄博市| 兴国县| 汝南县| 读书| 信宜市| 平泉县| 中山市| 仁怀市| 报价| 东丰县|