1

I need help with a plot in python. I used the example dataset mpg.

import pandas as pd
import numpy as np

from plotnine import *
from plotnine.data import *
import matplotlib.pyplot as plt
%matplotlib inline

mpg.head()
mpg = mpg.loc[(mpg.manufacturer=="audi") | (mpg.manufacturer=="jeep") ]
p = ggplot(aes(x='displ', y='manufacturer'), mpg)

I obtain this plot: enter image description here But I would like the shapes are free in y axis (because I have elements with overlapping), for example something like this: enter image description here

Thanks a lot!

JocHwo
  • 109
  • 2
  • 9

1 Answers1

1

Use position_jitter to add some randomness along the vertical direction.

+ geom_point(position=position_jitter(width=0, height=0.3))
has2k1
  • 2,095
  • 18
  • 16