• Skip to secondary menu
  • Skip to main content
  • Skip to primary sidebar

Python and R Tips

Learn Data Science with Python and R

  • Home
  • Python
  • Pandas
    • Pandas 101
  • tidyverse
    • tidyverse 101
  • R
  • Linux
  • About
    • Privacy Policy
You are here: Home / Python / Pie Chart in Python / Happy Pi(e) Day: How To Make Pie Chart in R and Python? (but Never Make it)

Happy Pi(e) Day: How To Make Pie Chart in R and Python? (but Never Make it)

March 14, 2019 by cmdlinetips

Happy Pi(e) Day! Pi Day is for celebrating the mathematical constant ? (pi) and it is on March 14 (3/14). It is also Albert Einstein’s birthday!

Today is probably the only day you can think of making a Pie Chart. Pie Chart has been around for a while and notorious for eye-candy but misleading plots. Just Google “why not to use pie charts”, you will find number of reasons. Two simple reasons are that it is really hard to get the right percentage from Pie chart and there are other better ways to visualize the same data.

How To Make Pie Chart in R?

Let us make a data frame to plot Pie chart.

df <- data.frame(
  variable = c("Yet to eat", "Eaten"),
  value = c(20, 80)
)

ggplot2’s coord_polar() function will help us make pie chart.

df %>% ggplot(aes(x = "", y = value, fill = variable)) +
  geom_col(width = 2) +
  scale_fill_manual(values = c("grey", "blue")) +
  coord_polar("y", start = pi / 3) +
  labs(title = "Happy Pi(e) Day")
Pie Chart in R
How to Make Pie Chart in R?

How To Make Pie Chart in Python?

Let us make a small data frame to make Pie Chart.

df = pd.DataFrame([8,2], 
        index=['Eaten', 'To Be Eaten'], 
        columns=['x'])

With Pandas’ plotting function plot, one can specify “kind=pie” to make Pie chart using Python.

df.plot(kind='pie', subplots=True, figsize=(6, 6))
Make Pie chart with Pandas Python?
How To Make Pie chart with Pandas Python?

Share this:

  • Share on Facebook (Opens in new window) Facebook
  • Share on X (Opens in new window) X

Filed Under: Pie Chart in Python, Pie Chart in R Tagged With: Pi Day, Pie Chart in Python, Pie Chart in R

Primary Sidebar

Subscribe to Python and R Tips and Learn Data Science

Learn Pandas in Python and Tidyverse in R

Tags

Altair Basic NumPy Book Review Data Science Data Science Books Data Science Resources Data Science Roundup Data Visualization Dimensionality Reduction Dropbox Dropbox Free Space Dropbox Tips Emacs Emacs Tips ggplot2 Linux Commands Linux Tips Mac Os X Tips Maximum Likelihood Estimation in R MLE in R NumPy Pandas Pandas 101 Pandas Dataframe Pandas Data Frame pandas groupby() Pandas select columns Pandas select_dtypes Python Python 3 Python Boxplot Python Tips R rstats R Tips Seaborn Seaborn Boxplot Seaborn Catplot Shell Scripting Sparse Matrix in Python tidy evaluation tidyverse tidyverse 101 Vim Vim Tips

RSS RSS

  • How to convert row names to a column in Pandas
  • How to resize an image with PyTorch
  • Fashion-MNIST data from PyTorch
  • Pandas case_when() with multiple examples
  • An Introduction to Statistical Learning: with Applications in Python Is Here
  • 10 Tips to customize ggplot2 title text
  • 8 Plot types with Matplotlib in Python
  • PCA on S&P 500 Stock Return Data
  • Linear Regression with Matrix Decomposition Methods
  • Numpy’s random choice() function

Copyright © 2026 · Lifestyle Pro on Genesis Framework · WordPress · Log in

Go to mobile version