ggplot2

How to specify `scale_color_manual()` in `python`, using `lets-plot`

How to specify `scale_color_manual()` in `python`, using `lets-plot` Question: My code is: import pandas as pd from lets_plot import * LetsPlot.setup_html() data = pd.read_csv(‘https://raw.githubusercontent.com/JetBrains/lets-plot-docs/master/data/mpg2.csv’) ggplot(data, aes(x="engine horsepower", y="miles per gallon")) + geom_point(aes(color="origin of car")) And the output is: In R, using ggplot2, I would manually set the colors by writing: … + scale_color_manual(values = c("US" …

Total answers: 1

Function equivalent to (python) seaborn's "set_context()" in (R) ggplot2?

Function equivalent to (python) seaborn's "set_context()" in (R) ggplot2? Question: A quite neat function of python’s library seaborn is to be able to all the sizes of the plots, labels and the majority of graph elements with a single command: set_context(context), for different contexts the sizes of figures are resized accordingly, so if context is …

Total answers: 1

Plotnine (ggplot) : Add whisker to end of geom_segment

Plotnine (ggplot) : Add whisker to end of geom_segment Question: I am doing this in python’s wonderful plotnine package, but hoping ggplotters may have a solution as well. Consider the following data and plot: df = pd.DataFrame({ ‘label’ : [‘A’,’B’,’C’,’D’], ‘start’ : [1, 1.5, 2.5, 1.75], ‘end’ : [3.85, 2.75, 4.25, 3], }) p = …

Total answers: 2

Drawing a sanky diagram of data flow to one point in R?

Drawing point to another point in R? Question: I have a information of migration data of different countries to Mexico. I want to represent it in a sanky. I am new to R and having a difficult time to produce it. Can someone please help me to achieve this? The destination is Mexico, so all …

Total answers: 3

How to set the physical size of plotnine png file

How to set the physical size of plotnine png file Question: I am using python’s plotnine package to create a series of plots. Often I need the plots to fit into a space x-cms by y-cms. I can control the size of the plot via: p.save(filename=path+’fig1.png’, height=10, width=12, units = ‘cm’, dpi=300) But this sets …

Total answers: 2

Python (matplotlib) equivalent of stacked bar chart in R (ggplot)

Python (matplotlib) equivalent of stacked bar chart in R (ggplot) Question: I am looking for an equivalent in python (matplotlib) of the following stacked bar chart created in R (ggplot): The dummy data (in R) looks like this: seasons <- c("Winter", "Winter", "Winter", "Spring", "Spring", "Spring", "Summer", "Summer", "Summer", "Fall", "Fall", "Fall") feelings <- c("Cold", …

Total answers: 3

Is position_dodge2() working for python with plotnine?

Is position_dodge2() working for python with plotnine? Question: I’m using ggplot in python with plotnine, I have this piece of code: my_plot_availability = (ggplot(df) + aes(x=’time_elapsed’,y=’mean’,fill=’policy’) + geom_bar(position=position_dodge(),stat = “identity”, color = “black”,size = 0.5) + geom_errorbar(aes(ymin=’mean-error’, ymax=’mean+error’), width=.2,position=position_dodge(.9)) + facet_wrap(‘mobility’) + scale_fill_manual([“darkgray”, “gray”]) + labs(x = “Time elpased [s]”) + labs(y = “Mean content …

Total answers: 2

is there gridExtra/cowplot type package in Python to use with Plotnine to align subplots (i.e. marginal distributions)

is there gridExtra/cowplot type package in Python to use with Plotnine to align subplots (i.e. marginal distributions) Question: This is related to the following posts on aligning subplots in ggplot2 in R: Scatterplot with marginal histograms in ggplot2 How to plot Scatters with marginal density plots use Python? Perfectly align several plots There are many …

Total answers: 2

Plotnine rotating labels

Plotnine rotating labels Question: 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. Asked By: sdgaw erzswer || Source Answers: Plotnine is basically a clone of ggplot, you can call (almost) exactly that. Here’s an example : import pandas …

Total answers: 1