- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to create pie chart in base R with labels?
A pie chart is a circular representation of data which is created for either nominal data or ordinal data. The slices in the pie chart depends on the magnitude of the data values. If we want to create a pie chart in base R with then pie function can be used along with labels argument.
Check out the Examples given below to understand how it can be done.
Example
To create a pie chart in base R with labels, use the following command −
x<-sample(1:20,8) pie(x)
Output
If you execute the above given command, it generates the following Output −
To create a pie chart in base R with labels add the following code to the above snippet −
x<-sample(1:20,8) pie(x,labels=LETTERS[1:8])
Output
If you execute all the above given snippets as a single program, it generates the following Output −
To create a pie chart in base R with labels add the following code to the above snippet −
x<-sample(1:20,8) pie(x,labels=c(1,2,5,4,3,7,8,6))
Output
If you execute all the above given snippets as a single program, it generates the following Output −
- Related Articles
- How to create pie chart in base R?
- How to create pie chart using plotly in R?
- Conditional removal of labels in Matplotlib pie chart
- How to create boxplot in base R without axes labels?
- How to create a plot with reversed Y-axis labels in base R?
- How to make the labels of a JavaFX Pie chart invisible?
- How to avoid overlapping of labels & autopct in a Matplotlib pie chart?
- How to create a Pie chart using JavaFX?
- How to create a plot with tick marks between X-axis labels in base R?
- ReactJS: How to Create a Pie Chart using Recharts?
- How to plot pie-chart with a single pie highlighted with Python Matplotlib?
- How to use mtext function to create the X-axis labels in base R?
- How to display X-axis labels with dash in base R plot?
- How to create a horizontal bar chart using ggplot2 with labels at inside end of the bars in R?
- How to create bar chart using ggplot2 with chart sub-title in R?
