Questions tagged [plotnine]

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.

179 questions
15
votes
2 answers

How to change the y axis to display percent (%) in Python Plotnine barplot?

How can we change y axis to percent, instead of a fraction using Plotnine library in Python? A MWE of a barplot is as follows: from plotnine import * from plotnine.data import mpg p = ggplot(mpg) + geom_bar(aes(x='manufacturer', fill='class'),…
15
votes
1 answer

Plotnine rotating labels

I was wondering how one rotates the x-labels, something in the lines of: theme(axis.text.x = element_text(angle = 90, hjust = 1)) in ggplot? Thank you.
sdgaw erzswer
  • 2,182
  • 2
  • 26
  • 45
14
votes
2 answers

Saving high-resolution images with plotnine

I'm trying to use plotnine to save a high-resolution png image. With a test dataset, this looks like: from plotnine import * import pandas as pd import numpy as np df = pd.DataFrame() df['x'] = np.arange(0,10,0.01) df['y'] = np.sin(df['x']) p =…
Blizzard
  • 198
  • 1
  • 10
7
votes
0 answers

ggplotly like function for python

In R there's a function (ggplotly), that converts ggplot2 plots to plotly graphs. In python you have plotnine for using ggplot, but is there a similar converter like ggplotly? There is a similar question, but is asking about the older (and I think…
fbence
  • 2,025
  • 2
  • 19
  • 42
7
votes
2 answers

plotnine - Any work around to have two plots in the same figure and print it

I have made two plots by using the plotnine in python. I know that is not really supported to draw subplots(here). I wonder if there is a way to work around and create the subplots in one figure. I thought of making them a Figure with…
George Sotiropoulos
  • 1,864
  • 1
  • 22
  • 32
7
votes
1 answer

Issue using qualitative brewer palettes in plotnine

I would like to use a brewer qualitative palette using plotnine, but I get the error: ValueError: Invalid color map name 'Set1' for type 'Sequential'. Valid names are: ['Blues', 'BuGn', 'BuPu', 'GnBu', 'Greens', 'Greys', 'OrRd', 'Oranges', 'PuBu',…
jcp
  • 749
  • 6
  • 21
6
votes
1 answer

Plotnine Wrap Text in Facet Wrap

I am plotting a faceted plot which has very long labels. I am translating some code from R to python. I am looking to wrap the text of the x-axis over multiple lines. I have shown the R code below. The R code q <- ggplot() + ... q +…
Anon.user111
  • 468
  • 1
  • 5
  • 16
6
votes
2 answers

Is there a way to prevent plotnine from printing user warnings when saving ggplot objects to a file?

I'm building a simulation tool in python that outputs a number of plots using plotnine. However, for each individual plot I save, I get the following error messages: C:\Users\tarca\Anaconda3\lib\site-packages\plotnine\ggplot.py:706: UserWarning:…
6
votes
2 answers

Plotnine: How remove the ggplot:(xxx) type annoying text output when plotting a graph

Running jupyter notebook (python) Plotting using Python Plotnine library I plot and below the output graphic is annoying "ggplot2: (number)" output Normally you would put a ; at the end of your notebook cell, but it doesn't seem to supress the…
TexasTom
  • 309
  • 1
  • 2
  • 6
6
votes
2 answers

Getting ModuleNotFoundError: No module named 'plotnine' when import on Jupyter Notebook

I'm following a plotnine tutorial to do some plotting on Jupyter Notebook. But when I imported from plotnine import * I got an error: ModuleNotFoundError: No module named 'plotnine'. I'm new on Jupyter and plotnine. Have tried different things…
Tyler
  • 97
  • 1
  • 2
  • 9
5
votes
1 answer

How do I use scale_color_manual in Python?

I've been using ggplot for a long time now and am very comfortable using it in R. I am working in Python right now for school and I am having the toughest time understanding this error. When I try to use scale_color_manual to manually assign colors…
AyeTown
  • 831
  • 1
  • 5
  • 20
5
votes
2 answers

Plotting in sorted order using Plotnine

I have a dataframe I am attempting to plot. I would like the data points to appear in sorted order along the x-axis in my plot. I have tried sorting the dataframe prior to passing it to ggplot, however my order gets disregarded. My data is as…
Adam Conrad
  • 166
  • 1
  • 11
4
votes
0 answers

plotnine geom_density memory and performance issues

I am running into memory and performance issues when trying to implement a density plot using python's plotnine. Consider the below dataset with 3 variables and 50,000 observations. This is not a large dataset. The below code took 15 minutes to…
brb
  • 1,123
  • 17
  • 40
4
votes
1 answer

Add Regression Line Equation and R-Square to a PLOTNINE

It is easy to get a linear best fit of data in plotnine --using stat_smooth(method="gls"). However, I can't figure out how to get out the coefficients to the best fit line or the R2 value. Ggplot in R has a stat_regline_equation() function that does…
4
votes
2 answers

Python Plotnine - Create a stacked bar chart

I've been trying to draw a stacked bar chart using plotnine. This graphic represents the end of month inventory within the same "Category". The "SubCategory" its what should get stacked. I've built a pandas dataframe from a query to a database. The…
Ramiro
  • 43
  • 1
  • 5
1
2 3
11 12