plotnine is a python plotting package that implements a "Grammar of Graphics" . It is based on the R package ggplot2 and has an API that is similar.
Questions tagged [plotnine]
179 questions
2
votes
1 answer
How to arrange different plots in rows and column in python if we are making plots by using plotnine package?
In R, we could plot each graph independently and then arrange all or some of the graphs easily by packages like gridExtra.
p1 <- ggplot(aes(x1,y1), data=df) + geom_point()
p2 <- ggplot(aes(x2,y2), data=df) + geom_point()
grid.arrange(p1, p2,…

Kashish Jain
- 21
- 5
2
votes
1 answer
Error trying to create count labels for geom_bar
I am trying to create a bar plot with labels using plotnine. According to the documentation, you can use label="stat(count)" in the aesthetic for the geom_text to print the position count for each bar. This is the equivalent of using the ..count..…

Howard Clark
- 21
- 1
2
votes
1 answer
plotting a pdf together with a histogram using plotnine in python
I have the following data:
import pandas as pd
from plotnine import *
gd_sp_tmp = pd.DataFrame({
'variable': {0: 'var1', 1: 'var1', 2: 'var1', 3: 'var1', 4: 'var1', 5: 'var1', 6: 'var1', 7: 'var1', 8: 'var1',
9:…

quant
- 4,062
- 5
- 29
- 70
2
votes
1 answer
Is ggplot2 for python via plotnine not supported anymore?
Eventhough I get a proper diagram (yeay!), I also get this warning each time I run ggplot:
FutureWarning: Attribute 'is_copy' is deprecated and will be removed in a future version.return object.__setattr__(self, name, value)
I use Python 3.6…

Bendaua
- 331
- 1
- 2
- 11
2
votes
1 answer
plotnine - mapping variable to scale_color_gradient
I am trying to plot a histogram with a color scale from blue to white.
gg = pd.DataFrame()
gg['x'] = u
p = ggplot(aes(x='x'),gg) +
geom_histogram(aes(fill='..count..'),binwidth=0.1)
p = p + scale_color_gradient(low='blue',high='white')
print(p)
If…

bill fite
- 43
- 5
2
votes
2 answers
Python plotnine increase distance between tick marks
I am trying to create a grouped bar chart using plotnine ggplot.
bar graph
As you can see the x tick marks are too close to each other and the labels are cluttered. How can I increase the distance between these tick labels?
ggplot(test, aes(x =…

Skywind555
- 31
- 1
- 7
2
votes
1 answer
KeyError in `plotnine` (ggplot wrapper for python)
I am trying to use plotnine to build graphs and I keep coming across the same KeyError problem when I want to plot just the x-axis. See the traceback error below.
A sample of my data is:
WORD TAG TOPIC Value
0 hey aa 1 …

owwoow14
- 1,694
- 8
- 28
- 43
1
vote
2 answers
Using manual colors for ggplot in Python
I'm trying to assign custom color palette to the plot. Values can be between 0 and 4 and for values 0-1, 1-2, 2-3, 3-4 I'd like to assign given color (e.g. "#C5FABE", "#F5D562", "#E89A3F", "#CF3E3E")
data table has columns for date, variable_name…

Dominik Roszkowski
- 2,715
- 1
- 19
- 46
1
vote
1 answer
plotnine:: is there a better way to refer args of facet_wrap in after_stat
I wants to show percentages for bar plots using plotnine with facet_wrap and stat = 'count'.
(Of course I can do it with preparation of values and stat = 'identity', but I want to avoid it.)
When I give the arg of facet_wrap to aes, I can refer it…

cuttlefish44
- 6,586
- 2
- 17
- 34
1
vote
1 answer
How to replicate a table from R to python using Matplotlib or Plotly
I am trying to replicate a table, which is currently produced in R, in python implementing plotnine library. I am using facet.grid with two variables (CBRegion and CBIndustry).
I have found a similar problem, however, it is also done in R. I…

Carpe Diem
- 13
- 1
- 3
1
vote
1 answer
Plotnine : Secondary y-axis (dual axes)
I am using python's wonderful plotnine package. I would like to make a plot with dual y-axis, let's say Celsius on the left axis and Fahrenheit on the right.
I have installed the latest version of plotnine, v0.10.1.
This says the feature was added…

brb
- 1,123
- 17
- 40
1
vote
1 answer
Plotnine (ggplot) : Set the direction legend elements are populated when specifying n rows
I am doing this in plotnine, but hoping ggplotters can assist as well.
Consider the following plot:
df = pd.DataFrame({
'date' : pd.date_range(start='30/09/2019', periods=11, freq='Q').repeat(6),
'variable' : ['A','B','C','D','E','F']*11,
…

brb
- 1,123
- 17
- 40
1
vote
1 answer
Python ModuleNotFoundError: No module named 'patsy' when using ggplot
I am attempting to run the following code to plot the explained variance after applying PCA on my dataframe:
(ggplot(pcaDF, aes(x = "Principal Components", y = "expl_var")) + geom_line() + geom_point())
However, I keep on getting this error…

sums22
- 1,793
- 3
- 13
- 25
1
vote
1 answer
Python translate matplotlib to a plotnine chart
I am currently working through the book Hands On Machine Learning and am trying to replicate a visualization where we plot the lat and lon co-ordinates on a scatter plot of San Diego. I have taken the plot code from the book which uses the code…

John Smith
- 2,448
- 7
- 54
- 78
1
vote
0 answers
The PlotnineError: "For loess smoothing, install 'scikit-misc'"
When I try to fit a curve with plotnine,it had a error that couldn 't run
That's my code
import pandas as pd
import numpy as np
from plotnine import *
import skmisc
df=pd.read_csv('Scatter_Data.csv')
plot_loess=(ggplot( df, aes('x','y')) +
…

ほしの凉
- 11
- 2