Plotnine bar plot order by variable

I have a question on ordering bar plots. For example: http://pythonplot.com/#bar-counts (ggplot(mpg) + aes(x='manufacturer') + geom_bar(size=20) + coord_flip() + ggtitle('Number of Cars by...

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',...

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...

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...

pandas equivalent of fct_reorder

Is there a way of reordering a pandas data frame column based on its relationship to another categorical column in the same data frame, akin to fct_reorder from the forcats package in R? A friend...

plotnine/ggplot - changing legend positions

I have this dataframe: df = pd.DataFrame({'ymin': {0: 0.0, 1: 0.0, 2: 0.0, 3: 0.0, 4: 0.511, 5: 0.571, 6: 0.5329999999999999, 7: 0.5389999999999999}, 'ymax': {0: 0.511, 1: 0.571, ...

conda update InvalidSpecError

I am trying to update a conda environment: conda update --all but get the following Fetching package metadata ............. InvalidSpecError: Invalid spec: =20190808 output of conda list is as...

How to control facet height and width in plotnine?

I have seen this post regarding ggplot2: https://stackoverflow.com/questions/52341385/how-to-automatically-adjust-the-width-of-each-facet-for-facet-wrap I was wondering: how can I achieve the same...

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...

plotnine doesn't add legend

I'm using plotnine to plot two graphs in the same plot. one graph uses the 'b' values from the dataframe you'll see below, and another one uses the values from 'c'. All I need is to show a simple...

Plotnine's scale fill and axis position

I would like to move the x-axis to the top of my plot and manually fill the colors. However, the usual method in ggplot does not work in plotnine. When I provide the position='top' in my...

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,...

CondaEnvException: Pip failed. I am getting a pip subprocess error when trying to create an environment in conda using a .yml file

I am trying to create an environment in conda using a .yml file. Here are the commands i have run, git clone https://github.com/fastai/fastai cd fastai conda env create -f environment.yml The...

Add statistically significant difference between bars to plotnine plot (ggpubr equivalent)

In many plots one wants to highlight the statistical significance of an observed difference between some results. This task can be done in R using the ggpubr() or the geom.signif() extension. An...

How to add legend in ggplot/plotnine for multiple curves

Here is a sample code which I am using to plot two curves. How can I add the legends to the plot? I saw some post where it was suggested to add color within aes but that throws the...

Plotting data from different datasets using plotnine and pandas

First off, I think it would be helpful to offer some background about what I want to do. I have a time-series dataset that describes air quality in a region, with hour resolution. Each row is an...

Celery + Flask + Docker, consumer: Cannot connect to amqp://admin:**@rabbit:5672/myhost: failed to resolve broker hostname

Background I am building a web application that uses Flask for the backend framework. The application uses Celery to handle all the time-consuming tasks as background tasks as to not block the...

Python-ggplot: Adding moving average to plot

p = ggplot(cases, aes(x="Specimen date", y="Daily lab-confirmed cases", group = 1)) + geom_point() + geom_line() + labs(title = "Daily COVID-19 Cases") p.save(filename = date_today, height=5,...

Annotations varying by subplot with plotly-express?

Suppose I want to make a subplot like this in which each facet has its own y scale: import plotly.express as px fig = px.scatter(px.data.iris(), x='sepal_length', y='sepal_width',...

Fit non-linear curve using Plotnine

Here's a working sample for producing linear curves for some user-defined metrics.. How can I have it fitted to a non-linear curve? def plot(version, str_metric): metric1 = [0.459, 0.5844,...

plotnine: How to caption?

I have a plot and I'd like to make the "source: JHU" line into a caption. There are a number of issues some open and others closed regarding this in plotnine's github. It has been brought to my...

plotnine: UserWarning: Starting a Matplotlib GUI outside of the main thread will likely fail

I am trying to use plotnine to generate some graphs. I import the required libraries: from plotnine import * from plotnine.data import mpg And then, if I run the following code in PyCharm I get...

Hourly heatmap graph using Python’s ggplot2 implementation ‘plotnine’?

I am trying to create an hourly heatmap from within Python. A code example of this graph made in R is available here: r-graph-gallery.com/283-the-hourly-heatmap.html. It relies on ggplot2. There...

Changing color of each bar for geom_bar in plotnine

I'm making some bar charts in plotnine of counts on a single variable (based on survey responses). I'm currently using this code: (ggplot(df, aes ('age_cat3')) + geom_bar(color='#F6F6F6',...

reverse order of discrete x axis in plotnine

In python, I am trying to reverse the order of my x-axis so that 2015 is on the far left and 2019 is on the right. The goal is to then have 2019 on the bottom after I coord_flip() the plot. See...

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...

Plotnine theme element_blank() doesn't seem to work - perhaps I'm not importing the package correctly?

I've created a state map and would like to remove the x-axis and y-axis as these don't provided any value for this plot. map_population_by_county = ( ggplot(map_population_by_county_data) +...

The 'pynndescent' distribution was not found and is required by the application error

I was trying to run this tutorial and it gives the following error on 'import cell2location' (cell 3, line 15), DistributionNotFound: The 'pynndescent' distribution was not found and is required...

How to place geom_text labels outside the plot boundary in plotnine

Using plotnine I am trying to plot line segments and annotate each segment on the right hand side of the plot. I am following examples on plotnine online documentation, however the text on the...

Sudden Tensorflow / Keras Google Colab dependency problems `AttributeError: module 'tensorflow._api.v1.compat.v2' has no attribute '__internal__'`

I have running a machine learning model (Matterport's Mask R-CNN) in google colab for a couple of weeks. All of a sudden today I am unable to run any of my notebooks due to I think some kind of...