आपकी ऑफलाइन सहायता

BACK
49

सी प्रोग्रामिंग

149

पाइथन प्रोग्रामिंग

49

सी प्लस प्लस

99

जावा प्रोग्रामिंग

149

जावास्क्रिप्ट

49

एंगुलर जे.एस.

69

पी.एच.पी.
माय एस.क्यू.एल.

99

एस.क्यू.एल.

Free

एच.टी.एम.एल.

99

सी.एस.एस.

149

आर प्रोग्रामिंग

39

जे.एस.पी.





डाउनलोड पी.डी.एफ. ई-बुक्स
R - R Pie Chart

pie chart ये user के द्वारा दिए गए vector के मुताबिक circle के slices का वर्णन करता है और हर slice को label दिया जाता है |

pie chart के लिए pie() function का इस्तेमाल किया जाता है | pie() function पर दिए हुए vectors के elements positive होना जरुरी होता है |

Syntax for pie() Function in R

pie(vector, labels, main, col, border, lty, clockwise)

Parameter for pie() Function in R

vector : vector. यहाँ पर vector दिया जाता है और उसपर numeric elements दिए जाते है |

labels : vector. यहाँ पर circle के किये हुए विभागों को नाम दिए जाते है |

main : string. यहाँ पर pie chart का title दिया जाता है |

col : vector. यहाँ पर colors के नाम दिए जाते है |

border : string. यहाँ पर bordre color name दिया जाता है |

lty : numeric. यहाँ पर pie chart के line का type number में दिया जाता है |

clockwise : अगर TRUE होता है तो clockwise slices किये जाते है और अगर FALSE होता है तो anti-clockwise slices किये जाते है |


Simple Example for pie() Function in R

Source Code :
val = c(15,20,30,5)
labels = c('TV','Refrigerators','Cooler','AC')
pie(val, labels)
Output :


Add Title to a Pie Chart in R

Example पर pie chart को title दिया गया है |

Source Code :
val = c(15,20,30,5)
labels = c('TV','Refrigerators','Cooler','AC')
pie(val, labels, main = "Electronics")
Output :


Fill own colors in circle's slices in R

Example पर अपने खुद के colors से circle के slices को fill किया गया है |

Source Code :
val = c(15,20,30,5)
labels = c('TV','Refrigerators','Cooler','AC')
colors = c('red', 'green', 'blue', 'yellow')
pie(val, labels, main = "Electronics", col = colors)
Output :


Add Label as Percentages on Slices in R

Example पर label को percentages के रूप में दिखाया गया है |

Source Code :
val = c(15,20,30,5)
labels = c('TV','Refrigerators','Cooler','AC')
colors = c('red', 'green', 'blue', 'yellow')
per = round(100*val/sum(val), 1)
pie(val, labels = per, main = "Electronics", col = colors)
Output :


Change Pie Chart Line Type in R

Example पर line type को change किया गया है |

Source Code :
val = c(15,20,30,5)
labels = c('TV','Refrigerators','Cooler','AC')
colors = c('red', 'green', 'blue', 'yellow')
pie(val, labels, main = "Electronics", col = colors, lty = 2)
Output :


Change Pie Chart Border Color in R

Example पर pie chart की border को set किया गया है |

Source Code :
val = c(15,20,30,5)
labels = c('TV','Refrigerators','Cooler','AC')
colors = c('red', 'green', 'blue', 'yellow')
pie(val, labels, main = "Electronics", col = colors, border = 'red')
Output :


Set Circle's slices clockwise in R

Example पर clockwise; circle के slices को set किया गया है |

Source Code :
val = c(15,20,30,5)
labels = c('TV','Refrigerators','Cooler','AC')
colors = c('red', 'green', 'blue', 'yellow')
pie(val, labels, main = "Electronics", col = colors, border = 'red', clockwise = TRUE)
Output :


Create 3D pie chart in R

Example पर 3D pie chart को display किया गया है |

pie3D() Function के लिए plotrix इस library को import किया जाता है | इसे पहले R पर install किया जाता है |
For plotrix package installation : RGui > Packages > Install package(s)... > Select Plotrix and wait for some seconds

Custom Installation : go to https://cran.r-project.org/web/packages/plotrix/index.html and download plotrix package > RGui > Packages > Install package(s) from local zip files... > Open downloaded plotrix Zip file.

Source Code :
library(plotrix)

val = c(15,20,30,5)
labels = c('TV','Refrigerators','Cooler','AC')
colors = c('red', 'green', 'blue', 'yellow')
pie3D(val, labels = labels, main = "Electronics")
Output :


Explode 3D pie chart using explode() in R

Example पर pie chart में circle के slices को explode किया गया है |

Source Code :
library(plotrix)

val = c(15,20,30,5)
labels = c('TV','Refrigerators','Cooler','AC')
colors = c('red', 'green', 'blue', 'yellow')
pie3D(val, labels = labels, main = "Electronics", explode = 0.2)
Output :


R Pie Chart पर legend को describe करने के लिए यहाँ पर click करे |