In data visualization, a plot refers to a graphical representation of data. It is a visual display of data that allows us to easily identify patterns, relationships, and trends in the data.

Plots can take many forms, such as scatter plots, line graphs, bar charts, histograms, and more. The choice of plot type depends on the type of data being visualized and the type of insights that we want to extract from it. For example, a scatter plot might be used to show the relationship between two variables, while a histogram might be used to show the distribution of a single variable.

The use of plots is an important tool in data analysis and data communication because it allows us to present complex information in a way that is easy to understand and interpret. A well-designed plot can help us to identify outliers, trends, and patterns that may not be immediately apparent from raw data.

In the R program, the plot() function is used for plotting. It can be customizable in a variety of ways to produce more impressive styles of graphs. some of the arguments that are reasonable for the designs and styles in plot function are:

  • Shape of the data point                - pch
  • Size of the plot                             - cex
  • Colour of the plot                         - colors()
  • Connectivity between the points  - type
  • line type and width                       - lty and lwd

Let's see the examples with R-code.

Generating datasets a and b, and visualising the graph with the standard plot() syntax: 

a = 1:10 b = runif(10,5,15)
plot(a,b)
We can even plot multiple graphs in a single picture with different colours by using "col", and in different line types and widths by using lty and lwd. 
par(mfrow = c(1,3)) plot(a,b, type = 'l',col = "green", lwd = 6, lty = 2) plot(a,b, type = 'l',col = "yellow", lwd = 10,lty=3) plot(a,b, type = 'l',col = "orange", lwd = 5, lty=7)
The line types and widths with different colours of the data points are increasing which is clearly illustrated in the sequence shown above.

The shape and size of the data points which are highlighted in the plot, it can be customizable by using the "pch" - Plot Characters and cex arguments. We can change the size of the data points from .5 (it will show 50% smaller than normal because the default is 1) to 2. Then the pch contains 25 characters that are shown below figure and two graphs explain the pch and cex arguments important in the plot() command.
par(mfrow = c(1,2)) plot(a,b, type = 'p',col = "blue",pch=11, cex=.5) plot(a,b, type = 'p',col = "red",pch=23, cex=2)
By using multiple colours and plot characters are used in this example.
plot(a,b, type = 'p',col = c("red", "violet","black"),pch=c(14,15,16), cex=2)

We can define a heading for the plot with a "main" argument. Then x-axis and y-axis are also defined by using "xlab and "ylab" arguments in plot() syntax.
plot(a,b, type = 'p',col = "red",pch=23, cex=2, main = "Example plot", xlab = "x-axis", ylab = "y-axis")
The type of plots with different colours are represented in the image for a better understanding.
par(mfrow = c(2,3)) plot(a,b, type = 'b',col = "violet",pch=23, cex=2, main = "Type - b") plot(a,b, type = 'h',col = "black",pch=23, cex=2, main = "Type - h") plot(a,b, type = 's',col = "brown",pch=23, cex=2, main = "Type - s") plot(a,b, type = 'p',col = "red",pch=23, cex=2, main = "Type - p") plot(a,b, type = 'c',col = "green",pch=23, cex=2, main = "Type - c") plot(a,b, type = 'o',col = "green",pch=23, cex=2, main = "Type - o")
In this article, the plot() command in R is explained with Source code and figures. The examples which are mentioned above are just to understand the plot command arguments. Visualizing the data is the best way to convey the matter in the data. So select the perfect and suitable plot argument for your data.

Post a Comment

The more you ask questions, that will enrich the answer, so whats your question?

Previous Post Next Post

Translate

AKSTATS

Learn it 🧾 --> Do it 🖋 --> Get it 🏹📉📊