offers data science lesson videos made simple!

Sign up or log in to Magoosh Data Science.

How to Make an R Plot Table

Plotting graphs from tabular data is commonly done in data analytics. It gives a better interpretation of the tabular data and also gives insights into interesting properties related to the data. Depending on what properties of data are important, table data can be visualised accordingly. The function used for this purpose is plot.table. Let us look at what this function is and how to use it.

Function: plot.table

This function basically is a plot function for tables. Depending on the type of table, this gives a plot of the table as the output. One-dimensional tables are plotted as bars. Two or more dimensional tables are plotted as mosaic plots.

To plot a table, simply type ‘plot(table_name)’ in the console or your R code. Where ‘table_name’ is the input table that is to be plotted. There are other arguments that can be input in this function to alter the output plot according to desired features.
The arguments are:

  • type – plotting type
  • ylim – range of y axis
  • lwd – line width for bars (one dimensional tables)
  • xlab – x axis label
  • ylab – y axis label

Let us take a simple example of a plot of one dimensional table.

How to Make an R Plot Table -magoosh

In this simple example, we have first created a table of 100 random numbers and plotted it. As we can see we have obtained a bar graph which is the default case for a plot of a table.

Likewise, let us take an example of a plot of multi-dimensional table.

The above plot is the result when we input ‘ plot(HairEyeColor) ‘ in the console. The ‘HairEyeColor’ is a data set in R that gives hair and eye color data of students. The above plot is the plot of the tabular data. Note that we obtain a mosaic plot because the table is multi-dimensional.

The various plotting types are:

  • p – points
  • s – stair steps
  • l – lines
  • o – overplotted points and lines
  • h – histogram-like vertical lines
  • b,c – points(empty if “c”) joined by lines
  • n – does not produce any points or lines

Let us try these as inputs:

Input = plot (table,type=”b”, main=”normanl table”,lwd=3)

Input = plot (table,type=”c”, main=”normal table”,lwd=2)

Input = plot (table,type=”h”, main=”normal table”,lwd=2)

So depending on what kind of plot we want, we can add arguments to our function as seen in the above examples.


Plotting tables is a very basic feature of R that gives a visual interpretation of tabular data. The plots give a summary of the table in a graphical format. They are pretty useful to get an overview of data.

Comments are closed.

Magoosh blog comment policy: To create the best experience for our readers, we will only approve comments that are relevant to the article, general enough to be helpful to other students, concise, and well-written! 😄 Due to the high volume of comments across all of our blogs, we cannot promise that all comments will receive responses from our instructors.

We highly encourage students to help each other out and respond to other students' comments if you can!

If you are a Premium Magoosh student and would like more personalized service from our instructors, you can use the Help tab on the Magoosh dashboard. Thanks!